dzek (varez) Posted June 30, 2010 Share Posted June 30, 2010 so get pack to previous post and re-read it. you messed up something, thats all. good idea - rewrite whole script (writing same thing again is faster) but you have to focus and watch out on every step. think, and try to expect every possible data on every function etc Link to comment
Spider Pork Posted June 30, 2010 Author Share Posted June 30, 2010 I have experimented some stuff with tonumber. This... is Sparta!! tonumber(getAccountData(account, "wwacc.timesSpawned")) ... returns nil for some reason. Anyone knows why? Link to comment
50p Posted June 30, 2010 Share Posted June 30, 2010 Because you can't convert boolean to a number Find you one setAccountData where you change value of "wwacc.timesSpawned" and make sure the value is not boolean. The code you showed sets timesSpawned twice and in both cases it's 0. Find the line where you change it to true or false. It's not possible that account data changes by itself. So what does getAccountData( playerid, "wwacc.timesSpawned" ) return? Link to comment
Spider Pork Posted July 4, 2010 Author Share Posted July 4, 2010 This is kinda weird. The variable is always a number until I restart the server. Then it becomes a boolean (false)... I've output its value everywhere I set it and also created a command to see it. It always sends a number, but when I restart the server it messes up to a boolean. I've also rewritten the whole script, here's the new login/register/spawning/test command code: function spawnHandler(posX, posY, posZ, spawnRotation, theTeam, theSkin, theInterior, theDimension) local account = getPlayerAccount(source) if account == false then outputChatBox("Error: You have to log in to spawn.", source, 255, 0, 0) cancelEvent() elseif account ~= false then if getAccountData(account, "wwacc.skin") == false or getAccountData(account, "wwacc.skin") == nil then setAccountData(account, "wwacc.skin", 0) end if getAccountData(account, "wwacc.justDied") == true then triggerClientEvent("showGUI_deathSelect", getRootElement()) end setAccountData(account, "wwacc.timesSpawned", getAccountData(account, "wwacc.timesSpawned")+1) outputChatBox(tostring(getAccountData(account, "wwacc.timesSpawned")), source) end end addEventHandler("onPlayerSpawn", getRootElement(), spawnHandler) function command_test(playerSource, commandName, ...) outputChatBox(tostring(getAccountData(getPlayerAccount(playerSource), "wwacc.timesSpawned"))) end addCommandHandler("test", command_test) function loginHandler(player, username, password) local account = getAccount(username, password) if account ~= false then if logIn(player, account, password) == true then triggerClientEvent("hideLoginWindow", player) setPlayerName(player, username) outputChatBox(tostring(getAccountData(account, "wwacc.timesSpawned")), source) if getAccountData(account, "wwacc.justDied") == true then triggerClientEvent("showGUI_deathSelect", getRootElement()) elseif getAccountData(account, "wwacc.needsSelect") == true then triggerClientEvent("showGUI_teamSelect", player) elseif getAccountData(account, "wwacc.timesSpawned") > 0 then fadeCamera(player, true) spawnPlayer(player, getAccountData(account, "wwacc.xPos"), getAccountData(account, "wwacc.yPos"), getAccountData(account, "wwacc.zPos"), getAccountData(account, "wwacc.angle"), getAccountData(account, "wwacc.skin"), getAccountData(account, "wwacc.interior")) setCameraTarget(player, player) elseif getAccountData(account, "wwacc.timesSpawned") == 0 then if getAccountData(account, "wwacc.team") == 1 then fadeCamera(player, true) spawnPlayer(player, 245.9324, 1990.0793, 17.6406, 180, 287, 0, 0) setElementInterior(player, 0) setElementHealth(player, 100) setPedArmor(player, 0) setCameraTarget(player, player) elseif getAccountData(account, "wwacc.team") == 2 then fadeCamera(player, true) spawnPlayer(player, -2681.7974, 2151.6648, 55.8125, 180, 100, 0, 0) setElementInterior(player, 0) setElementHealth(player, 100) setPedArmor(player, 0) setCameraTarget(player, player) end end else outputChatBox("Error: Invalid username or password", source, 255, 0, 0) end else outputChatBox("Error: An account with that username doesn't exist.", source, 255, 0, 0) end end addEvent("onLogin", true) addEventHandler("onLogin", getRootElement(), loginHandler) function registerHandler(player, username, password) local account = getAccount(username) if account ~= false then if logIn(player, account, password) then triggerClientEvent("hideLoginWindow", player) setPlayerName(player, username) outputChatBox("You have been successfully logged in.", player) else outputChatBox("Error: Invalid password.", player, 255, 0, 0) end else account = addAccount(username, password) setAccountData(account, "wwacc.team", 0) setAccountData(account, "wwacc.needsSelect", true) setAccountData(account, "wwacc.waitingMoney", 0) setAccountData(account, "wwacc.money", 0) setAccountData(account, "wwacc.adminLevel", 0) setAccountData(account, "wwacc.muted", false) setAccountData(account, "wwacc.regimentMember", 0) setAccountData(account, "wwacc.regimentLeader", 0) setAccountData(account, "wwacc.hasRadio", false) setAccountData(account, "wwacc.radioFreq", 0) setAccountData(account, "wwacc.timesSpawned", 0) if logIn(player, account, password) == true then triggerClientEvent("hideLoginWindow", player) triggerClientEvent("showGUI_teamSelect", player) setPlayerName(player, username) outputChatBox("You have been successfully logged in.", player) else outputChatBox("Error: Fatal error occured. Please contact an administrator for help.", player, 255, 0, 0) end end end addEvent("onRegister", true) addEventHandler("onRegister", getRootElement(), registerHandler) What am I doing wrong? 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