rublisk19 Posted January 1, 2012 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!!
12p Posted January 1, 2012 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.
rublisk19 Posted January 1, 2012 Author Posted January 1, 2012 don't work error: attempt to call global 'getLocalPlayer' a nil value
Otto Posted January 1, 2012 Posted January 1, 2012 Wrong section I think. Why don't you try in "Scripting" section?
karlis Posted January 1, 2012 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
12p Posted January 1, 2012 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.
Recommended Posts