justn Posted August 26, 2014 Posted August 26, 2014 Hey guys, I made a supernick script it was working fine at first, but then i updated the server and it doesnt work.. This is the function the error is in: function setPlayerSuperNick( player,command,choice,supernick ) if ( command == "sp" ) then if ( not isGuestAccount( getPlayerAccount ( player ) ) ) then if ( choice ) then if ( choice == "set" ) then if ( supernick ) then if (tonumber(string.sub(getElementData(player,"Cash"), 2)) >= tonumber(price)) then setAccountData(getPlayerAccount(player),"supernick",supernick) outputChatBox(supercolor.."[superNick]: #FFFFFF"..getPlayerName(player).." #FFFFFFhas bought a "..supercolor.."supernick#FFFFFF for #00FF00$#FFFFFF"..price.." #FFFFFF ( "..supercolor..getAccountData(getPlayerAccount(player),"supernick").."#FFFFFF )",root,255,255,255,true) outputChatBox(supercolor.."[superNick]: #FFFFFFYou have bought a "..supercolor.."supernick #FFFFFFfor #00FF00$#FFFFFF"..price,player,255,255,255,true) setElementData(player,"Cash",tonumber(string.sub(getElementData(player,"Cash"), 2))-tonumber(price)) else outputChatBox(supercolor.."[superNick]: #FFFFFFYou must have atleast #00FF00$#FFFFFF"..price.."#FFFFFF to buy a "..supercolor.."supernick",player,255,255,255,true) end else outputChatBox(supercolor.."[superNick]: #FFFFFFYou haven't put a "..supercolor.."supernick #FFFFFF",player,255,255,255,true) end elseif ( choice == "remove" ) then if ( getAccountData(getPlayerAccount(player),"supernick" ) ~= "nil" ) then outputChatBox(supercolor.."[superNick]: #FFFFFF"..getAccountData(getPlayerAccount(player),"supernick" ).."#FFFFFF has removed his "..supercolor.."supernick #FFFFFF( "..supercolor..getPlayerName(player).. " #FFFFFF)",player,255,255,255,true) setAccountData(getPlayerAccount(player),"supernick",nil) outputChatBox(supercolor.."[superNick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been removed",player,255,255,255,true) else outputChatBox(supercolor.."[superNick]: #FFFFFFYou do not have a "..supercolor.."supernick #FFFFFFto remove",player,255,255,255,true) end else outputChatBox(supercolor.."[superNick]: #FFFFFFFormat is: /sp set/remove "..supercolor.."supernick",player,255,255,255,true) end else outputChatBox(supercolor.."[superNick]: #FFFFFFFormat is: /sp set/remove "..supercolor.."supernick",player,255,255,255,true) end else outputChatBox(supercolor.."[superNick]: #FFFFFFYou must login to set/remove your "..supercolor.."supernick",player,255,255,255,true) end end end addCommandHandler("sp",setPlayerSuperNick) addEventHandler("onPlayerCommand",getRootElement(),setPlayerSuperNick) ERROR: sp_server.lua:22: bad argument #1 of 'sub'(string expected,got boolean) Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Bonsai Posted August 26, 2014 Posted August 26, 2014 What else you need? The error message provides everything you need to know. No idea which line is 22 in this part of the script, probably line 7. getElementData returns false if there is no data. Now you should be able to fix that.
justn Posted August 27, 2014 Author Posted August 27, 2014 Line 22 is line 7 I just never copied the entire code... and there is data. Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Anubhav Posted August 27, 2014 Posted August 27, 2014 Use tostring on getElementData. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
justn Posted August 27, 2014 Author Posted August 27, 2014 I won't help someone who takes community resources then edit it by adding his name and his server name on it. Huh ? you're acting as if I asked for your help, well guess what ? I didn't ask for your help. and Secondly I made this script 100% myself. Please don't post if you don't have anything helpful to say Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Moderators IIYAMA Posted August 27, 2014 Moderators Posted August 27, 2014 Try: if ((tonumber(string.sub(tostring(getElementData(player,"Cash")), 2)) or 0) >= tonumber(price)) then Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
justn Posted August 28, 2014 Author Posted August 28, 2014 @nabil1478; You're saying it as if i asked you personally for help .. and as I said, I made this script 100% myself, please give me the link to where i 'stole' this please ? since you wanna be such a smartass.. you don't have the full code, you don't even know what the script does.. so please, show the link. @IIYAMA I'll test it later, currently on my phone. thanks ! @Anubhav Thanks for your help Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Moderators IIYAMA Posted August 29, 2014 Moderators Posted August 29, 2014 I won't waste my time, I've just added my point here. If you want to say something very negative, don't you think you need a bit of proof for that? Richt now you are destroying somebody his reputation, when hè is only asking for help. Next time keep it for yourself, unless you know where it is from. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Anubhav Posted August 29, 2014 Posted August 29, 2014 First as IIYAMA said another no problem @ twerky See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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