Jump to content

armor script not working:/


Xwad

Recommended Posts

Hi please help i made a script that makes possible that when a player spawn in class Heavy then he will get Armor.

Its not working.. Debugscript: WARNING: heavy/server.lua:2: Bad argumentum @ getElementData' [Expected element at argument 1,got nil]

Server.lua

  
function givePlayerArmor ( player ) 
if getElementData(localPlayer,"Class") == "Heavy" then 
setPedArmor ( player, 100 )     
end 
end  
addEventHandler ("onPlayerSpawn", getRootElement(), givePlayerArmor ) 
  
  

Link to comment
addEventHandler( "onPlayerSpawn", root, 
    function (  ) 
    if getPlayerTeam ( source ) then 
        if getTeamFromName ( "Heavy" ) then 
        setPedArmor( source,100 ) 
            end 
        end 
    end 
) 

addEventHandler( "onPlayerSpawn", root, 
    function (  ) 
        if getPlayerTeam ( source ) and getTeamName(getPlayerTeam ( source )) == "Heavy" then 
        setPedArmor( source,100 ) 
        end 
    end 
) 
  

Link to comment

is this that you want?

function onPlayerSpawnHandler() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    if (isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("VIP"))) then 
        setPlayerArmor(source, 100) 
    end 
end 
addEventHandler("onPlayerSpawn", getRootElement(), onPlayerSpawnHandler) 

Link to comment
is this that you want?
function onPlayerSpawnHandler() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    if (isObjectInACLGroup("user."..getAccountName(account), aclGetGroup("VIP"))) then 
        setPlayerArmor(source, 100) 
    end 
end 
addEventHandler("onPlayerSpawn", getRootElement(), onPlayerSpawnHandler) 

He want this: when a player spawn in class Heavy then he will get Armor. :wink:

Link to comment

only this is working but it gives the armor higgledy-piggledy sometimes it gives the armor for other classes.. And no debugscript.

  
addEventHandler('onPlayerSpawn',root, 
function ()     
if getElementData( source, 'Class' ) == 'Heavy' then      setPedArmor( source,100 )     
end 
end ) 
  

Edited by Guest
Link to comment

I have a similar script that makes possible if i choose medic class then i can heal myself with pressing H

  
function heal () 
    local theHealth = getElementHealth (localPlayer) 
    if getElementData(localPlayer,"Class") == "Medic" then 
        if ( theHealth < 100 ) then 
            setElementHealth ( localPlayer, getElementHealth(localPlayer) + 50 ) 
            unbindKey("h","down",heal) 
            setTimer (bindTheKeys , 7000, 1 ) 
        end 
    end 
end 
  
function bindTheKeys () 
  bindKey ( "h", "down", heal )  
end 
bindTheKeys() 
  

Link to comment

i tryed this but this is also not working!! why the fuck is the script bugging!!??

  
addEventHandler("onPlayerSpawn", root, 
function() 
    if getElementData(source, "Class") == "Heavy" then 
        setPedArmor(source, 100) 
    end 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    if getElementData(source, "Class") == "Medic" then 
        setPedArmor(source, 0) 
    end 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    if getElementData(source, "Class") == "Engineer" then 
        setPedArmor(source, 0) 
    end 
end) 
  
addEventHandler("onPlayerSpawn", root, 
function() 
    if getElementData(source, "Class") == "Sniper" then 
        setPedArmor(source, 0) 
    end 
end) 
  

Link to comment

this is the part where the Heavy class is. (Spawn_locations.map)

  
"Heavy" friendlyfire="false" > 
            "Heavy's have more hp and more weapon demage."/> 
            "0" green="0" blue="205" /> 
             
            "SS-soldier" id="11" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier2" id="12" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier3" id="13" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier4" id="14" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier5" id="15" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier6" id="16" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier7" id="17" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier8" id="18" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier9" id="19" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "SS-soldier10" id="20" > 
                "-2368.8291015625" y="-2185.1970214844" z="33.529106140137" rot="91.98" /> 
            
            "46" ammo="1" /> 
            "16" ammo="2" /> 
            "23" ammo="24" /> 
            "31" ammo="200" /> 
            "36" ammo="4" /> 
            
                "-2098.5178222656" y="-2079.3725585938" z="71.461433410645" />  
                "-2313.4711914063" y="-2294.9970703125" z="50.461433410645" /> 
            
        
  

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...