Jump to content

armor script not working:/


Xwad

Recommended Posts

Posted

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 ) 
  
  

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

2vjs7it.jpg
Posted
addEventHandler( "onPlayerSpawn", root, 
    function (  ) 
    if getPlayerTeam ( source ) then 
        if getTeamFromName ( "Heavy" ) then 
        setPedArmor( source,100 ) 
            end 
        end 
    end 
) 

آن يكون فكر المرء مختلآ , خيرآ من آن يكون فكره محتلآ !

my nick name in the game : =x=|DoN|=x= or 7eJAzZy- ( ͡° ͜ʖ ͡°)

http://community.multitheftauto.com/ind ... &id=337164 my profile

Posted
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 
) 
  

Posted
function Armor() 
       if getElementData(source, "class") == Heavy then 
          setPlayerArmor(source, 100) 
       end 
end 
addEventHandler("onPlayerSpawn", root, Armor) 

 

 

Posted

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) 

 DUyJ810.gif

Posted
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:

Posted (edited)

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
Posted
addEventHandler("onPlayerSpawn", root, 
function() 
    if getElementData(source, "Class") == "Heavy" then 
        setPedArmor(source, 100) 
    else 
        setPedArmor(source, 0) 
    end 
end) 

CiTLh.png
Posted

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() 
  

Posted

i know this medic script is right i just wrote it becaouse its similar then the heavy armor script. And the amror script is not working becaouse sometime other classes get the armor too.

Posted
The code is 100% right, Where you set "Class" element data

??? lol there is no element data called "Class" in this script : https://community.multitheftauto.com/?p=resources&s=details&id=1152

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

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) 
  

Posted
i already edited this spawn script!!!

Man try to show us your edited script

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

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" /> 
            
        
  

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