ElexTron Software
Members-
Posts
24 -
Joined
-
Last visited
Everything posted by ElexTron Software
-
Hello! I've got this code: client.lua -- GUI Init Stuff GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} GUIEditor_Window[1] = guiCreateWindow(289,156,220,324,"Objects",false) GUIEditor_Grid[1] = guiCreateGridList(9,26,202,253,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1],2) GUIEditor_Button[1] = guiCreateButton(16,289,187,26,"Create Object",false,GUIEditor_Window[1]) showCursor( false ) guiSetVisible ( GUIEditor_Window[1], false ) guiSetInputEnabled(false) -- Fills the Gridlist with Objects function fillList() local searchMax = 0 local node = xmlLoadFile("conf/objects.xml") local id = 0 local name = 0 guiGridListClear( GUIEditor_Grid[1] ) local column = guiGridListAddColumn(GUIEditor_Grid[1],"Objects", 1) if node then while ( true ) do local object = xmlFindChild ( node, "object", searchMax ) if ( not object ) then break end id = tonumber ( xmlNodeGetAttribute ( object, "id" ) ) name = xmlNodeGetAttribute ( object, "name" ) guiGridListSetItemText ( GUIEditor_Grid[1], searchMax, column, name, false, false ) guiGridListSetItemData ( GUIEditor_Grid[1], searchMax, column, id ) searchMax = searchMax + 1 end else outputChatBox("Resource 'objects' Error: 0x000001") end xmlUnloadFile( node ) end addCommandHandler("fillHerUp", fillList) fillList() -- Shows or Hides the GUI function toggleGUI( key, keyState ) if guiGetVisible ( GUIEditor_Window[1] ) then showCursor( false ) guiSetVisible ( GUIEditor_Window[1], false ) guiSetInputEnabled(false) else showCursor( true ) guiSetVisible ( GUIEditor_Window[1], true ) guiSetInputEnabled(true) end end addCommandHandler( "obj", toggleGUI ) bindKey( "o", "down", "obj" ) function makeObj( button ) if button == "left" then local row, col = guiGridListGetSelectedItem ( GUIEditor_Grid[1] ) local objModel = guiGridListGetItemData ( GUIEditor_Grid[1], row, col ) triggerServerEvent("onObjectMake", objModel, getLocalPlayer() ) end end addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], makeObj, false ) But everytime I run it, it returns the error message ( outputChatBox("Resource 'objects' Error: 0x000001") ). So I'm guessing it doesn't load the XML file. I have set the paths correctly, with "objects.xml" being in the "conf" folder. Help is appreciated. Nevermind - Solved!
-
Oops! Never mind! It was a simple mistake! target = getPedOccupiedVehicle( tplayer ) I forgot to set the target to the vehicle! Thanks!
-
Okay, now all the script seems to work correctly and the "detach" etc message comes up, but the vehicles do not appear to be attached in-game. client.lua function starty() attached = false -- Variable to Check Before Attaching/Detaching carrying = false -- Player Being Carried vehicle = 548 -- Carrying Vehicle (Cargobob) outputChatBox("values set "..getPlayerName(getLocalPlayer()).."") end addEventHandler("onClientResourceStart", getRootElement(), starty) -- Vehicles NOT Able to Be Carried local unAbleList = { {592},{577},{511},{548},{512},{593},{425},{520},{417},{487},{553},{488},{497},{563},{476},{447},{519},{460},{469},{513} -- All the Aircraft } function connect() local player = getLocalPlayer() local x,y,z = getElementPosition(player) outputChatBox("trying to connect...") if (attached == false) then -- If NOT Carrying Vehicle... if (getElementModel(getPedOccupiedVehicle(player)) == vehicle) then -- If Player is in Carrier Vehicle... outputChatBox("in heli...") local target = false for i, tplayer in ipairs(getElementsByType('player')) do local tx, ty, tz = getElementPosition(tplayer) -- Search Through Players, Find One Within 3 Pixels, Check Vehicle... if (tplayer ~= player) and getPedOccupiedVehicle(tplayer) and getDistanceBetweenPoints2D(x,y,tx,ty) < 5 then target = tplayer break end end carrying = target -- Search Through Players, Find One Within 3 Pixels, Check Vehicle... if (target) then triggerServerEvent("onVehicleAttach", getRootElement(), target, player) --attachElements(target, player, 0, 0, -2) carrying = target attached = true outputChatBox("attached! to: "..getPlayerName(target).."") end end elseif (attached == true) then -- Else if Carrying Vehicle... outputChatBox("detached!") triggerServerEvent("onVehicleDetach", getRootElement(), carrying) --detachElements(player) attached = false carrying = false end end function bindFunc() bindKey("2", "down", connect) end addCommandHandler("attacher", bindFunc) function bindUs(source, commandname, target) --attachElements(target, getLocalPlayer(), 0,0,-2) attachElements(getPedOccupiedVehicle(target), getPedOccupiedVehicle(getLocalPlayer()), 0, 0, -2) end addCommandHandler("put", bindUs) server.lua addEvent("onVehicleAttach", true) addEvent("onVehicleDetach", true) function attach(target, player) attachElements(target, player, 0, 0, -2) outputChatBox("ATTACHED "..getPlayerName(target).." to "..getPlayerName(player).."") end addEventHandler("onVehicleAttach", getRootElement(), attach) function detach(target) detachElements(target) outputChatBox("DEEEETACHED") end addEventHandler("onVehicleDetach", getRootElement(), detach)
-
Hmm... I'll try it out thanks, I see now. And I'm not sure yet but possibly, yes, it should be serverside.
-
Hello! I have made a client-side script that allows players in a Cargobob to carry other players in vehicles and also release them by using attach/detach elements. However, it is not fully working. My script is below: attached = false -- Variable to Check Before Attaching/Detaching carrying = false -- Player Being Carried vehicle = 548 -- Carrying Vehicle (Cargobob) outputChatBox("values set "..getPlayerName(getLocalPlayer()).."") -- Vehicles NOT Able to Be Carried local unAbleList = { {592},{577},{511},{548},{512},{593},{425},{520},{417},{487},{553},{488},{497},{563},{476},{447},{519},{460},{469},{513} -- All the Aircraft } function connect() local player = getLocalPlayer() local x,y,z = getElementPosition(player) outputChatBox("trying to connect...") if (attached == false) then -- If NOT Carrying Vehicle... if (getPedOccupiedVehicle(player) == vehicle) then -- If Player is in Carrier Vehicle... outputChatBox("in heli...") local target = false local tx = 0 local ty = 0 local tz = 0 -- Not Used local breaker = 0 local playList = getElementsByType("player") local rnd = 0 repeat breaker = breaker + 1 rnd = math.random(1, #playList) target = playList[rnd] tx,ty,tz = getElementPosition(target) outputChatBox("breaker: "..breaker.."") until ( ((getDistanceBetweenPoints2D(x,y, tx,ty) < 20) and (getPedOccupiedVehicle(target)) and ( (target == player) == false)) or (breaker > 100) ) -- Search Through Players, Find One Within 3 Pixels, Check Vehicle... attachElements(target, player, 0, 0, -2) carrying = target attached = true outputChatBox("attached! to: "..getPlayerName(target).."") end elseif (attached == true) then -- Else if Carrying Vehicle... outputChatBox("detached!") detachElements(player) attached = false carrying = false end end function bindFunc() bindKey("2", "down", connect) end addCommandHandler("attacher", bindFunc) It doesn't work, but I can't find why. Everything looks laid out properly and everything but it's not working. Can someone please help me with this script? Any help is greatly appreciated. EDIT: I kindly ask that you do not steal this script (in-progress) or anything, I just want help with it. UNSOLVED!
-
How To Get the Selected Item on a Gridlist?
ElexTron Software replied to ElexTron Software's topic in Scripting
Thanks! It works now! server.lua function burnPlayer ( player ) setPedOnFire( player, true ) end addEvent( "burn", true ) addEventHandler( "burn", getRootElement(), burnPlayer ) client.lua function initGUI() -- Creates the Parents GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} -- Window GUIEditor_Window[1] = guiCreateWindow(108,174,450,333,"ElexTronic Punish Panel",false) -- Gridlist playerList = guiCreateGridList(19,36,113,277,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(playerList,2) -- Fills the Gridlist With Players local column = guiGridListAddColumn(playerList,"Player", 1) if column then for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) guiGridListSetItemData ( playerList, row, column, getPlayerName ( player ) ) end end -- Creates the Buttons GUIEditor_Button[1] = guiCreateButton(206,35,216,31,"Slap Him Into Last Week",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], slapPlayer, false ) GUIEditor_Button[2] = guiCreateButton(206,76,216,31,"Shoot Him Out Of His Vehicle",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], ejectPlayer, false ) GUIEditor_Button[3] = guiCreateButton(206,119,216,31,"Remove All His Weapons",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], unarmPlayer, false ) GUIEditor_Button[4] = guiCreateButton(206,166,216,31,"Third-Degree Burn Him",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], burnPlayer, false ) GUIEditor_Button[5] = guiCreateButton(206,210,216,31,"Gooch Choke Him",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], chokePlayer, false ) GUIEditor_Button[6] = guiCreateButton(206,257,216,31,"Warp Him",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], warpPlayer, false ) end addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource() ), initGUI ) function burnPlayer( button ) if button == "left" then local row, col = guiGridListGetSelectedItem ( playerList ) local selected = guiGridListGetItemData ( playerList, row, col ) outputChatBox( tostring(selected)) local nName = getPlayerFromName( selected ) triggerServerEvent("burn", nName, nName ) end end -
Hello. I have a script that creates kind-of a "Admin" GUI. I have the Interface set how I want it, but I'm having trouble getting the selected item in the gridlist. Here is my script: function initGUI() -- Creates the Parents GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Grid = {} -- Window GUIEditor_Window[1] = guiCreateWindow(108,174,450,333,"ElexTronic Punish Panel",false) -- Gridlist playerList = guiCreateGridList(19,36,113,277,false,GUIEditor_Window[1]) guiGridListSetSelectionMode(playerList,2) -- Fills the Gridlist With Players local column = guiGridListAddColumn(playerList,"Player",0.2) if column then for id, player in ipairs(getElementsByType("player")) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText ( playerList, row, column, getPlayerName ( player ), false, false ) guiGridListSetItemData ( playerList, row, column, getPlayerName( player ) ) end end -- Creates the Buttons GUIEditor_Button[1] = guiCreateButton(206,35,216,31,"Slap Him Into Last Week",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], slapPlayer, false ) GUIEditor_Button[2] = guiCreateButton(206,76,216,31,"Shoot Him Out Of His Vehicle",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], ejectPlayer, false ) GUIEditor_Button[3] = guiCreateButton(206,119,216,31,"Remove All His Weapons",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], unarmPlayer, false ) GUIEditor_Button[4] = guiCreateButton(206,166,216,31,"Third-Degree Burn Him",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], burnPlayer, false ) GUIEditor_Button[5] = guiCreateButton(206,210,216,31,"Gooch Choke Him",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], chokePlayer, false ) GUIEditor_Button[6] = guiCreateButton(206,257,216,31,"Warp Him",false,GUIEditor_Window[1]) addEventHandler ( "onClientGUIClick", GUIEditor_Button[4], warpPlayer, false ) end addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource() ), initGUI ) function burnPlayer( button ) if button == "left" then local row, col = guiGridListGetSelectedItem ( playerList ) local selected = guiGridListGetItemData ( playerList, row, col ) setPedOnFire( selected, true ) end end I know how to add the functions to execute the command, but I don't know how to get the Player from the gridlist to use the command on. Please help me solve this. Thanks in advance. EDIT: I have edited the code a little and added the burnPlayer function to demonstrate my problem. Every time I try to burn a player using the button, it gives me: Bad argument @ 'setPedOnFire' To my understanding by this, selected was passed an invalid argument, therefore being false.
-
Oh wow! I didn't even notice that! Thanks! I guess I should look more at the code next time!
-
"onClientPlayerWeaponFire" Trouble
ElexTron Software replied to ElexTron Software's topic in Scripting
Okay I just edited the code a little and this works, though it is more limited: function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if weapon == 23 and getElementType(hitElement)=="vehicle" then -- If the player shoots with a minigun, and hits another player... createProjectile(getLocalPlayer(),39,hitX,hitY,hitZ) end end -- Add this as a handler so that the function will be triggered every time the local player fires. addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) -
"onClientPlayerWeaponFire" Trouble
ElexTron Software replied to ElexTron Software's topic in Scripting
Thanks but that still doesn't solve the problem. -
Is it possible to add a new weapon for real MTA use? Like say, for example, edit the weapons.xml inside the freeroam resource and add a new weapon? I kind of doubt this because I think that the weapons are built into GTA instead of externally defined, but I was still wondering...
-
"onClientPlayerWeaponFire" Trouble
ElexTron Software replied to ElexTron Software's topic in Scripting
Well when I run it and start the resource no message is displayed whatsoever, whether a Satchel was placed or not, and no sound is played when I use the Satchel Detonator. EDIT: But no, no errors show up on the Console. -
Hello! I have this code (Ace_Gambit is the original creator of it) for mounting weapons onto a vehicle's passenger side for shooting that I got from an old topic. The thing is, when I try to use it, it doesn't work. Here are all the files: rocket_client.lua local root = getRootElement() local player = getLocalPlayer() local toggleVehicleWeapon = false local previousTick = getTickCount() local projectileType = 21 function updateVehicleWeapon(source, dataName) if (getElementType(source) == "vehicle" and dataName == "toggleVehicleWeapon") then toggleVehicleWeapon = (getElementData(source, dataName) and isPedInVehicle(player)) end end function callbackDataChange(dataName) updateVehicleWeapon(source, dataName) end function callbackVehicleEnter(thePlayer, seat) updateVehicleWeapon(source, "toggleVehicleWeapon") end function callbackRender() if (getControlState("vehicle_fire") and toggleVehicleWeapon) then if (getTickCount() > (previousTick + 150) and previousTick > 0) then fireProjectile() end end end function fireProjectile() local vehicle = getPedOccupiedVehicle(player) local gun = false local gX, gY, gZ = 0, 0, 0 local gRotX, gRotY, gRotZ = 0, 0, 0 local pX, pY, pZ = 0, 0, 0 local vX, vY, vZ = 0, 0, 0 local currentLoSOffset = 3.5 local zPosOffset = 1.1 local thrust = 2.0 previousTick = 0 if (vehicle) then if (#getAttachedElements(vehicle) > 0) then gun = getAttachedElements(vehicle)[1] if (gun) then gX, gY, gZ = getElementPosition(gun) gRotX, gRotY, gRotZ = getElementRotation(gun) pX = gX - math.sin(-math.rad(gRotZ + 90)) * currentLoSOffset pY = gY + math.cos(-math.rad(gRotZ + 90)) * currentLoSOffset pZ = gZ + zPosOffset vX = math.sin (math.rad((gRotZ + 90))) * thrust vY = math.cos(math.rad((gRotZ + 90))) * thrust vZ = 0 createExplosion(pX, pY, pZ, 5, true, -1.0, false) createProjectile(player, projectileType, pX, pY, pZ, 0, nil, 0, 0, 0, vX, vY, vZ) end end end previousTick = getTickCount() end function changeProjectileType(commandName, arg) projectileType = tonumber(arg) or 21 end addEventHandler("onClientElementDataChange", root, callbackDataChange, true) addEventHandler("onClientVehicleEnter", root, callbackVehicleEnter, true) addEventHandler("onClientRender", root, callbackRender, true) addCommandHandler("guntype", changeProjectileType) rocket_server.lua local guns = { [470] = { ["xPosOffset"] = 1.0, ["yPosOffset"] = 0, ["zPosOffset"] = 0 } } function attachMod(playerSource, commandName) local vehicle = getPedOccupiedVehicle(playerSource) local gun = false if (vehicle) then gun = guns[getElementModel(vehicle)] or false if (gun) then attachElements(createObject(2985, 0, 0, -100, 0, 0, 0), vehicle, gun.xPosOffset, gun.yPosOffset, gun.zPosOffset, 0, 0, 90) setElementData(vehicle, "toggleVehicleWeapon", true) end end end function detachMod(playerSource, commandName) local vehicle = getPedOccupiedVehicle(playerSource) if (vehicle) then for _, element in ipairs(getAttachedElements(vehicle)) do destroyElement(element) end setElementData(vehicle, "toggleVehicleWeapon", false) end end addCommandHandler("mount", attachMod, false) addCommandHandler("unmount", detachMod, false) meta.xml <meta> <info author="Ace_Gambit" version="1.0" type="script"/> <script src="rocket_server.lua" /> <script src="rocket_client.lua" type="client" /> </meta> Can someone please identify the problem? Thanks in advance.
-
Hello! I am trying to make it so that: A) Every time a player fires a Silenced Pistol, a Satchel is placed at the pistol's target. B) Every time the Satchel Detonator is used, a detonation sound is played. I have made a script for this, but it is not working: client.lua -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if weapon == 23 then -- If Silenced Pistol is Used... local aimSpot = getPedTarget(getLocalPlayer()) if aimSpot then createProjectile(getLocalPlayer(),39,getElementPosition(aimSpot)) then -- Then Create a Satchel at Target if Targeting outputChatBox("Satchel Created", source) else outputChatBox("no target!", source) end end if weapon == 40 then -- If Satchel Detonator is Used... local satchSnd = playSound("detonate.mp3") -- Play Detonation Sound end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc) I have a folder named modweapons where I put my three files in it; the script above, detonate.mp3, and this meta.xml file: <meta> <info type="script" author="Cecil G. Bowen" Version="1.0" name="ModWeapons" /> <script src="script.lua" type="client" /> <file src="detonate.mp3" /> </meta> Help would be really appreciated! Thanks in advance!
-
Okay thanks for your help, it works now. And about the snd in playSound, it is a global sound from another part of the script. I didn't post the whole script, just the function that wasn't working. And I knew that math.random already returned a number, but after trying everything else (and forgetting the then after elseif ) I tried anything.
-
Yeah thanks, I got it now.
-
Okay I have this script: function dieHandler() local aa = math.random(1,3) local ab = tonumber(aa) if ab == 1 then outputChatBox("Damn! Now we'll never get that Weed!", source, 255, 0, 0, true) elseif ab == 2 outputChatBox("...Knew I should've gotten Chris to do it!", source, 255, 0, 0, true) elseif ab == 3 outputChatBox("Next time we get the stuff, you ain't in!", source, 255, 0, 0, true) end setSoundVolume(snd, .35) local sound = playSound("sounds/wasted.mp3") end addEventHandler("onClientPlayerWasted", getResourceRootElement(getThisResource()), dieHandler) But it won't work. If I remove everything and just make it output a message it works (aka i remove the random stuff). Does anyone know why? Thanks in advance.
-
I guess I should've been more specific. I want to hide my blip (and my blip only) from the radar of everyone else's map if say, I use the command /hide. And then make it re-appear if I use /hide-stop. How would I do this? EDIT: Okay I found the functions, but I don't know how to make it appear to only certain players yet...
-
Is there a way/function to hide a player's radar blip? So that you can't see where he is on the map? If so, can someone please help me.
-
Okay now that I think about it I know what you mean, but what if the shooter has, say, a rocket launcher and he aims next to the admin and the explosion kill him?
-
Thanks! I realize the problem now, and after all it's just my second script.
-
Okay I made a script that is supposed to give a player back his health when he gets damaged, but it isn't working! The files are below: hp.lua --add an event handler for the onPlayerDamage event function hp ( attacker, weapon, bodypart, loss ) --when a player is damaged if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then setElementHealth(source, getElementHealth(source)+loss) if (getElementType( attacker ) == "player" then setElementHealth(attacker, getElementHealth(source)-loss) end end end addEventHandler ( "onPlayerDamage", getRootElement (), hp ) meta.xml <meta> <info author="Cecil G. Bowen" type="script" version="1.0" description="Infinite Health"/> <script src="hp.lua" type="server"/> </meta> Thanks in advance.
-
Thanks man, I'll check it out! And Lua does look somewhat similar to JavaScript.
-
Hey there! I'm new to this forum and since this is my first post, I'll introduce myself. I am and intermediate C++, GML (Game Maker), VBScript, and JavaScript programmer. I know very little of Java and Javascript, and have never had any experience with Lua. My question is, I want to make a simple kill script (that only works for the Admin, Mods, etc) that kills anyone; but, if a Mod tries to kill an Admin, it shows them a warning and doesn't kill the Admin. Seems simple enough. So will someone please make me an example script? Thanks in advance.