Jump to content

Invinciblity script script


TuRisMo

Recommended Posts

function noattack(attacker) 
     if getElementData(source,"invincible") then 
          setElementHealth(attacker,getElementHealth(attacker)-10) 
          cancelEvent() 
     end 
end 
addEventHandler("onClientPlayerDamage", attacker, noattack) 
  
function noVehicleDamage() 
    if (isPedInVehicle (source) == false) then return end 
        staffVehicle = getPedOccupiedVehicle(source) 
        setVehicleDamageProof(staffVehicle, true) 
end 
addEvent ("trololo", true ) 
addEventHandler("trololo", localPlayer, noVehicleDamage) 

Alright this script is supposed to make the Admin his car invincible. And when someone attacks him the attacker should get a 10 HP slap

Here's the debug message:

Line3: Bad Argument @getElementHealth

Line3: attempt to perform arithmetic on a boolean value

Line 7: addEventHandler[Expected element at argument 2, got nil]

Link to comment

At point in time of interpretation, Attacker must be defined at line 7 at addEventHandler, you also have it defined as a local variable in noattack. There are two problems here

1. attacker is local to noattack, meaning even if it was defined at interpret time, it would still be undefined except to noattack when called with argument.

2. attacker must be defined as a constant for it to work where addEventHandler() is sitting at. You have it being defined somewhere else as a local argument variable, being SET BY onClientPlayerDamage, there for, chicken and the egg problem. Its undefined before the time addEventHandler is interpreted, and defined when the event is called. This is not possible unless attacker is defined by a constant value and is global.

Remove attacker at Line 7 Argument 2 of addEventHandler and put getRootElement(). This fix will also remove the other listed errors (if my mind simulates correct)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...