Hi I'm new to MTA and Lua, as you can probably tell by now. After being introduced to it by an experienced Lua scripter, I tried to make my own script, but failed.
[17:31:36] WARNING: ammunation\server.lua:19: Bad argument @ 'addEventHandler Expected element at argument 2, got nil]
Server
function marker ()
ped = createPed (200, 0, -2, 5)
theMarker = createMarker ( 0, 0, 3, "cylinder", 1, 0, 255, 0, 170 )
end
addCommandHandler ("x", marker)
function takeCash ( thePlayer, command, amount)
takePlayerMoney ( thePlayer, 100 )
giveWeapon ( thePlayer , 31, 200 )
end
function consoleGive ( thePlayer, commandName, weaponID, ammo )
giveWeapon (thePlayer, 31, 200, true )
end
function gui ()
triggerClientEvent ( "onAmmunation", getRootElement(), ammunationHandler )
end
addEventHandler ( "onMarkerHit", theMarker, gui )
Client
function ammunationHandler ()
sx,sy,sz = guiGetScreenSize
window[1] = guiCreateWindow(sx/2, sy/2, 800/2, 300/2, "Buy Weapon", false)
weapon[1] = guiCreateButton(606, 316, 241, 83, "Buy Weapons", false, window[1])
end
addEvent ( "onAmmunation", true )
addEventHandler ( "onAmmunation", getRootElement(), ammunationHandler )