Xwad Posted April 14, 2015 Share Posted April 14, 2015 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
The Don Posted April 14, 2015 Share Posted April 14, 2015 addEventHandler('onPlayerSpawn',root, function () if getElementData( source, 'Class' ) == 'Heavy' then setPedArmor( source,100 ) end end ) Link to comment
Xwad Posted April 14, 2015 Author Share Posted April 14, 2015 it gives the armor now but it's bugging. It gives the armor higgledy-piggledy. I mean i choose heavy class and i get an armor but hen i die and choose another class i will get the armor again:/ Sometimes it does not give the armor when i choose class heavy:( maybe need i edit the spawn script? this is the spawn script https://community.multitheftauto.com/?p= ... ls&id=1152 Link to comment
HUNGRY:3 Posted April 17, 2015 Share Posted April 17, 2015 function givePlayerArmor ( source ) if getElementData( source,"Class") == "Heavy" then setPedArmor ( source, 100 ) end end addEventHandler ("onPlayerSpawn", getRootElement(), givePlayerArmor ) Link to comment
The Don Posted April 17, 2015 Share Posted April 17, 2015 addEventHandler( "onPlayerSpawn", root, function ( ) if getPlayerTeam ( source ) then if getTeamFromName ( "Heavy" ) then setPedArmor( source,100 ) end end end ) Link to comment
ALw7sH Posted April 17, 2015 Share Posted April 17, 2015 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
Xwad Posted April 18, 2015 Author Share Posted April 18, 2015 not works:( I thing the problem is becaouse my spawn script. Link to comment
HUNGRY:3 Posted April 18, 2015 Share Posted April 18, 2015 what does debugscript 3 say ? Link to comment
Dimos7 Posted April 18, 2015 Share Posted April 18, 2015 function Armor() if getElementData(source, "class") == Heavy then setPlayerArmor(source, 100) end end addEventHandler("onPlayerSpawn", root, Armor) Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 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
1LoL1 Posted April 19, 2015 Share Posted April 19, 2015 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. Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 (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 April 19, 2015 by Guest Link to comment
TAPL Posted April 19, 2015 Share Posted April 19, 2015 addEventHandler("onPlayerSpawn", root, function() if getElementData(source, "Class") == "Heavy" then setPedArmor(source, 100) else setPedArmor(source, 0) end end) Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 Sry I forgot to write the code ( i wrote it to my last post) Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 TAPL i tryed your script but its the same it gives the armor sometime to other calsses Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 i use this spawn script https://community.multitheftauto.com/?p= ... ls&id=1152 Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 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
ALw7sH Posted April 19, 2015 Share Posted April 19, 2015 The code is 100% right, Where you set "Class" element data Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 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. Link to comment
Walid Posted April 19, 2015 Share Posted April 19, 2015 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 Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 i already edited this spawn script!!! Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 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
Walid Posted April 19, 2015 Share Posted April 19, 2015 i already edited this spawn script!!! Man try to show us your edited script Link to comment
Xwad Posted April 19, 2015 Author Share Posted April 19, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now