Hola,
I've been busy recently trying to script a police job including a jailbreak. The triggerEvent is wrong, and i've got no idea what's wrong in it. If anyone could help me out, that'd be much appreciated.
function polices ( attacker, attackerweapon, bodypart, loss )
if attacker and getElementType(attacker) == "player" then
theTeam = getPlayerTeam ( attacker )
theWL = getPlayerWantedLevel ( source )
money = theWL * 2.5
if (attackerweapon == 3 or attackerweapon == 23) and (loss > 2 ) and (theWL > 0) then
if getTeamName( theTeam ) == "Police" or getTeamName( theTeam ) == "United States Army" or getTeamName( theTeam ) == "Sheriff Academy" then
setElementPosition (source, 4076.3999023438, -1788.5, 3.511967, true)
theName = getPlayerName ( source )
theCop = getPlayerName ( attacker )
outputChatBox( "*INFO* "..theName.." has been jailed and arrested by "..theCop.."", source, 255, 255, 0 )
local playeraccount = getPlayerAccount ( attacker )
givePlayerMoney (attacker, money)
setElementData(source, "isJailed", "true")
setTimer ( newEvent, 1000, 1 )
end
end
end
end
addEventHandler ("onPlayerDamage", getRootElement(), polices)
function newEvent()
theName = getPlayerName(source)
if getElementData(source, "isJailed") == "true" then
setElementData(source, "isJailed", "false")
setPlayerWantedLevel(source, 0)
end
end
addEvent("releasePlayer", true)
addEventHandler("releasePlayer", getRootElement(), newEvent)
So bassicly, i want to trigger this newEvent after a sec being in jail (1 sec just to test it out, will be changed after tho) but then debugscript tells me: Bad argument, expected element at argument 1, got nill (@ newEvent).
All help 'preciated,
cheers.