rublisk19 Posted January 1, 2012 Share Posted January 1, 2012 function expcalculate ( source, command ) setElementData(source, "EXP",tonumber(getElementData(source, "EXP"))+1) end setTimer(expcalculate, 20000,0) I get error : Bad argument @ 'getElementData' [Expected element ar argument 1, got nil] attempt to perform arithmetic on a nil value If you can pls fix this script to make working ;] . I need this to get exp every 20sec!! Link to comment
12p Posted January 1, 2012 Share Posted January 1, 2012 "source" is an invalid element type, because it's only used for event handlers. Just use your mind a bit, and think: "where the hell did I get source from?". So, if this is a client script, you could replace source by getLocalPlayer ( ), or a predefined player variable being called from getLocalPlayer ( ). local player = getLocalPlayer ( ) function expcalculate ( ) setElementData ( player, "EXP", tonumber ( getElementData ( player, "EXP" ) ) +1, true ) end setTimer ( expcalculate, 20000, 0 ) This will set player's EXP data to both server and client-side, you can call that element data from any side. Link to comment
rublisk19 Posted January 1, 2012 Author Share Posted January 1, 2012 don't work error: attempt to call global 'getLocalPlayer' a nil value Link to comment
Otto Posted January 1, 2012 Share Posted January 1, 2012 Wrong section I think. Why don't you try in "Scripting" section? Link to comment
karlis Posted January 1, 2012 Share Posted January 1, 2012 don't work error: attempt to call global 'getLocalPlayer' a nil value you was using serverside script. also you can use variable localPlayer Link to comment
Towncivilian Posted January 1, 2012 Share Posted January 1, 2012 Topic moved to Scripting section. Link to comment
12p Posted January 1, 2012 Share Posted January 1, 2012 also you can use variable localPlayer I prefer to define "player" as localPlayer. The script I gave you is client-side only. Link to comment
rublisk19 Posted January 1, 2012 Author Share Posted January 1, 2012 please close problem fixed Link to comment
Recommended Posts