
Spider Pork
Members-
Posts
60 -
Joined
-
Last visited
Everything posted by Spider Pork
-
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
I get no message if I register, disconnect and connect back on. But if I restart the server, it comes from this line: if(logIn(playerid, account, pass) == true) then As I said, it works until I restart the server. EDIT: There are no more errors when I log in after restarting the server, but it still doesn't spawn me. EDIT2: I've just noticed that there are two timesSpawned saves in the accounts file. I guess one of them is still the old boolean, while the other is a numeric one. They both reset though and give me no errors. -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
It's kinda hard to explain. So, let's say I register. If I disconnect and reconnect to my server and login, everything will work perfectly fine. But, if I restart the server itself, then it seems that timesSpawned in the accounts file resets for some reason. This is the handler that registers the player or logins them if they're already registered: function onRegister(playerid, user, pass) local account = getAccount(user, pass) if(account ~= false) then if(logIn(playerid, account, pass) == true) then triggerClientEvent("hideLoginWindow", playerid) onLog(playerid, account, pass) outputChatBox("You have been successfully logged in.", playerid) else outputChatBox("Error: Invalid password, username or already logged in.", playerid) end else account = addAccount(user, pass) setAccountData(account, "wwacc.xPos", x) setAccountData(account, "wwacc.yPos", y) setAccountData(account, "wwacc.zPos", z) setAccountData(account, "wwacc.interior", int) setAccountData(account, "wwacc.team", 0) setAccountData(account, "wwacc.needsSelect", true) setAccountData(account, "wwacc.timesSpawned", 0) setAccountData(account, "wwacc.waitingMoney", 0) setAccountData(account, "wwacc.money", 0) setAccountData(account, "wwacc.adminLevel", 0) setAccountData(account, "wwacc.muted", false) setAccountData(account, "wwacc.regimentLeader", 0) setAccountData(account, "wwacc.regimentMember", 0) setAccountData(account, "wwacc.hasRadio", false) setAccountData(account, "wwacc.radioFreq", 0) if(logIn(playerid, account, pass) == true) then local x, y, z = unpack(WandererSpawns[math.random(1, 13)]) setPlayerName(playerid, user) triggerClientEvent("hideLoginWindow", playerid) triggerClientEvent("showGUI_teamSelect", playerid) outputChatBox("You have been successfully registered and logged in.", playerid) else outputChatBox("Error: Invalid password, username or already logged in.", playerid) end end end Here's the handler that logins the player: function onLogin(playerid, user, pass) local account = getAccount(user, pass) if(account ~= false) then if(logIn(playerid, account, pass) == true) then triggerClientEvent("hideLoginWindow", playerid) onLog(playerid, account, pass) outputChatBox("You have been successfully logged in.", playerid) else outputChatBox("Error: Invalid password, username or already logged in.", playerid) end else outputChatBox("Error: Invalid username or password.", playerid) end end And here's the onLog function which you can spot in my code a lot of times: function onLog(playerid, account, pass) setPlayerName(playerid, getAccountName(account)) if(getAccountData(account, "wwacc.needsSelect") == true) then triggerClientEvent("showGUI_teamSelect", playerid) end if(getAccountData(account, "wwacc.timesSpawned") == nil or getAccountData(account, "wwacc.timesSpawned") == false) then setAccountData(account, "wwacc.timesSpawned", 0) end if(getAccountData(account, "wwacc.timesSpawned") > 0) then if(getAccountData(account, "wwacc.needsSelect") == false) then fadeCamera(playerid, true) spawnPlayer(playerid, getAccountData(account, "wwacc.xPos"), getAccountData(account, "wwacc.yPos"), getAccountData(account, "wwacc.zPos"), 0.0, getAccountData(account, "wwacc.skin"), getAccountData(account, "wwacc.interior"), 0, getAccountData(account, "wwacc.team")) setCameraTarget(playerid, playerid) end end if(getAccountData(account, "wwacc.timesSpawned") == 0 and getAccountData(account, "wwacc.needsSelect") == false) then if(getAccountData(account, "wwacc.team") == 1) then setAccountData(account, "wwacc.xPos", 245.9324) setAccountData(account, "wwacc.yPos", 1990.0793) setAccountData(account, "wwacc.zPos", 17.6406) fadeCamera(playerid, true) spawnPlayer(playerid, 245.9324, 1990.0793, 17.6406) setCameraTarget(playerid, playerid) setElementInterior(playerid, 0) setElementHealth(playerid, 100) setPedArmour(playerid, 0) end if(getAccountData(account, "wwacc.team") == 2) then setAccountData(account, "wwacc.xPos", -2681.7974) setAccountData(account, "wwacc.yPos", 2151.6648) setAccountData(account, "wwacc.zPos", 55.8125) fadeCamera(playerid, true) spawnPlayer(playerid, -2681.7974, 2151.6648, 55.8125) setCameraTarget(playerid, playerid) setElementInterior(playerid, 0) setElementHealth(playerid, 100) setPedArmour(playerid, 0) end end end -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
Bump Should I use some other account system? -
Nothing advanced, just optional arguments. Go to https://wiki.multitheftauto.com/wiki/AddCommandHandler and look at the 3rd server example. 4th shows you how you can join multiple arguments.
-
Just a note; you only create 2 UFO objects, 0 (with the handler) and 1 (with the timer). Also, when adding the handler, you should do this: addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), ufo0) And why create them separately?
-
Add an event on onPlayerChat, then cancel their message and create a chat bubble. Something like this: function proceedChatBubbles(message, messageType) if(messageType == 0) then -- Add the code how you want the chat bubbles to be. end cancelEvent() end addEventHandler("onPlayerChat", getRootElement(), proceedChatBubbles)
-
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
I've fixed the spawning thing. What I did is forward getLocalPlayer value to the server login event and then use it to call the other function... It works actually . Yes, I do. But I only check if the player spawned already before their current visit. I'm fiddling with the element data now. It always says "attempt to compare number with boolean", again... It works fine when I first register and login. I can also disconnect and reconnect back, but when I restart the server, it resets. What should I do? Should I use set/getElementData and then save it with set/getAccountData then reset it back by reading from the file? -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
Yep. I also tried with getAccountPlayer and getRootElement, which both returned the same error. -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
Triggered when a player logs in. function onLog(account) local account2 = getAccount(account) setPlayerName(source, account) if(getAccountData(account2, "wwacc.needsSelect") == true) then triggerClientEvent("showGUI_teamSelect", source) end if(getAccountData(account2, "wwacc.timesSpawned") == nil) then setAccountData(account2, "wwacc.timesSpawned", 0) end if(getAccountData(account2, "wwacc.timesSpawned") > 0) then if(getAccountData(account2, "wwacc.needsSelect") == false) then spawnPlayer(source, getAccountData(account2, "wwacc.xPos"), getAccountData(account2, "wwacc.yPos"), getAccountData(account2, "wwacc.zPos"), 0.0, getAccountData(account2, "wwacc.skin"), getAccountData(account2, "wwacc.interior"), 0, getAccountData(account2, "wwacc.team")) fadeCamera(source, true) setCameraTarget(source, source) end end if(getAccountData(account2, "wwacc.timesSpawned") == 0 and getAccountData(account2, "wwacc.needsSelect") == false) then if(getAccountData(account2, "wwacc.team") == 1) then setAccountData(account2, "wwacc.xPos", 245.9324) setAccountData(account2, "wwacc.yPos", 1990.0793) setAccountData(account2, "wwacc.zPos", 17.6406) spawnPlayer(source, 245.9324, 1990.0793, 17.6406) setPlayerInterior(source, 0) givePlayerMoney(source, 0) setPlayerHealth(source, 100) setPlayerArmour(source, 0) setPlayerTeam(source, 1) fadeCamera(source, true) setCameraTarget(source, source) end if(getAccountData(account2, "wwacc.team") == 2) then setAccountData(account2, "wwacc.xPos", -2681.7974) setAccountData(account2, "wwacc.yPos", 2151.6648) setAccountData(account2, "wwacc.zPos", 55.8125) spawnPlayer(source, -2681.7974, 2151.6648, 55.8125) setPlayerInterior(source, 0) givePlayerMoney(source, 0) setPlayerHealth(source, 100) setPlayerArmour(source, 0) setPlayerTeam(source, 2) fadeCamera(source, true) setCameraTarget(source, source) end end end -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
Yea, it works. Thanks. Though when I restart the server same error appears when trying to spawn. Also, this code... spawnPlayer(source, getAccountData(account2, "wwacc.xPos"), getAccountData(account2, "wwacc.yPos"), getAccountData(account2, "wwacc.zPos"), 0.0, getAccountData(account2, "wwacc.skin"), getAccountData(account2, "wwacc.interior"), 0, getAccountData(account2, "wwacc.team")) ... gives me the "Bad player pointer" error. What's wrong? -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
This is weird. I use this every time they spawn: local timesSpawned = getElementData(source, "wwacc.timesSpawned") + 1 setElementData(source, "wwacc.timesSpawned", timesSpawned) But still, when I output it with my test command, it always outputs "false". -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
I looked through the whole script and I never set a boolean value, only integer. -
"Error: Attempt to compare number with boolean"
Spider Pork replied to Spider Pork's topic in Scripting
It outputs "false", meaning it's a boolean. How do I set it an integer? -
Hello there! I can't seem to find the problem here. This line... if(getElementData(source, "wwacc.timesSpawned") > 0 and getElementData(source, "wwacc.needsSelect") == false) then ... gives me this error: Error: attempt to compare number with boolean It's not a boolean, at least it's not supposed to be. Is there any way to set the data type, like float, int, bool? Does anyone see the problem in that line of code? Help would be greatly appreciated, thanks.
-
Great job. Though I haven't found any way to add images. Have I missed something or they aren't included?
-
Then use the code I posted above ... Also, it would help a lot if you post the code you have in your script. Edit: Have you used guiSetEnabled on that button somewhere?
-
So you can't click on it? As in, the mouse cursor doesn't even appear? In that case, use showCursor.
-
You need to add an event handler for the button to work, else it'll just do nothing... function onClickButton(button, state, absoluteX, absoluteY) -- Put what it should do here. Also check which button the client clicked (left, middle, right), else it will work for all buttons in all states (click, release) end addEventHandler("onClientGUIClick", buttonName, onClickButton, false)
-
Where did you put that? For the server-side script, use this: showCursor(player, true, true) Or use this in a client-side script: showCursor(true, true)
-
Great work. I love the new chatbox .
-
You'll need this: https://wiki.multitheftauto.com/wiki/SetElementPosition Put it under an event which should trigger the teleport.
-
Hey there! My problem now is that an event doesn't trigger when it should. I used this for triggering: triggerClientEvent("sendChatMessage", source, "Hello there.") And I have added the event client-side: function sendChatMessage(text) local ptext = guiGetText(chatLabel) guiSetText(chatLabel, "" .. ptext .. "\n" .. text .. "") end addEvent("sendChatMessage", true) addEventHandler("sendChatMessage", getRootElement(), sendChatMessage) Though, suprisingly, the same event DOES trigger when I call it from the same server-side script, this one: triggerClientEvent("sendChatMessage", playerid, "You have been successfully registered and logged in.") I am guessing it is the two different player variables. One of them is source and the other one is playerid. I forward playerid from getLocalPlayer in another client-side script. What's wrong?
-
This is where it triggers the event: function onClickBtn(button, state) if(button == "left" and state == "up") then if(source == BtnAction) then if(guiGetSelectedTab(TabPanel) == TabLogin) then triggerServerEvent("onLogin", getRootElement(), getPlayerName(getLocalPlayer()), guiGetText(LoginUsername), guiGetText(LoginPassword)) else triggerServerEvent("onRegister", getRootElement(), getPlayerName(getLocalPlayer()), guiGetText(EditRegisterUsername), guiGetText(EditRegisterPassword)) end end end end
-
Anyone?
-
I see what you're trying to say. But the code I posted is in the server-side script, not the client-side. It uses triggerServerEvent because it's in the client-side script, right? The example from the wiki is in the client-side script.