marty000123 Posted April 14, 2017 Share Posted April 14, 2017 (edited) function spawnpanel() local acc = getPlayerAccount(source) if getAccountData(acc, "FirstLoginKek", false) then triggerClientEvent(acc, "spawnpanel") setAccountData(acc, "FirstLoginKek", true) outputChatBox("works", acc, 255, 0, 0) end end addEventHandler("onPlayerLogin", getRootElement(), spawnpanel) In this code, when players join the server for the first time, they get a message with ''works''. Their account data will be set to ''FirstLoginKek'', so if they join again, they won't see the message anymore. So I tried this in my server, I did not have the accountdata, but it didn't work. The ClientEvent didn't work, and the output didn't show up. This is the first time I work with getAccountData, so I'm not sure if this is the way to use it, but yeah help would be greatly appreciated. Edited April 14, 2017 by marty000123 Link to comment
Mr.Loki Posted April 14, 2017 Share Posted April 14, 2017 function spawnpanel() local acc = getPlayerAccount(source) if getAccountData(acc, "FirstLoginKek") == false then --wrong syntax triggerClientEvent(acc, "spawnpanel") setAccountData(acc, "FirstLoginKek", true) outputChatBox("works", acc, 255, 0, 0) end end addEventHandler("onPlayerLogin", getRootElement(), spawnpanel) You can use either: If getAccountData(account,"key") == false then Or If not getAccountData (account,"key") then Link to comment
SheriFF Posted April 14, 2017 Share Posted April 14, 2017 Replace if getAccountData(acc, "FirstLoginKek", false) then with if getAccountData(acc, "FirstLoginKek") == false then Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 setAccountData(acc, "team", green) if getAccountData(acc, "team") == green then Will this work? Link to comment
Moderators IIYAMA Posted April 14, 2017 Moderators Share Posted April 14, 2017 That depends if the variable `green` is available and if the `team` is the team name. You can't save elements inside accountdata, teams are elements. teamName = "green" -- getTeamName ( team theTeam )// https://wiki.multitheftauto.com/wiki/GetTeamName setAccountData(acc, "team", teamName) if getAccountData(acc, "team") == teamName then Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 (edited) 11 minutes ago, IIYAMA said: That depends if the variable `green` is available and if the `team` is the team name. You can't save elements inside accountdata, teams are elements. teamName = "green" -- getTeamName ( team theTeam )// https://wiki.multitheftauto.com/wiki/GetTeamName setAccountData(acc, "team", teamName) if getAccountData(acc, "team") == teamName then Alright, thanks. Edited April 14, 2017 by marty000123 Link to comment
Moderators IIYAMA Posted April 14, 2017 Moderators Share Posted April 14, 2017 local allTeamData = { ["Ghost Mercenaries"] = { spawnpoint = {-176.84535, 996.75055, 23.63281, 180, 287, 0} -- add more data if you want. }, ["Special Military Unit"] = { spawnpoint = {-176.84535, 996.75055, 23.63281, 180, 287, 0} -- add more data if you want. }, ["People's Protection Power"] = { spawnpoint = {-176.84535, 996.75055, 23.63281, 180, 287, 0} -- add more data if you want. } } function onDeath() -- get the player his account local acc = getPlayerAccount(source) -- is played logged in? if not isGuestAccount(acc) then local teamName = getAccountData(acc, "team") local teamData = allTeamData[teamName] -- get the data based on the teamName if teamData then local teamElement = getTeamFromName(teamName) if teamElement then setPlayerTeam(source, teamElement) spawnPlayer (source, unpack(teamData.spawnpoint)) else outputDebugString("<" .. tostring(getPlayerName(source)) .. "> " .. "can't find team") end else outputDebugString("<" .. tostring(getPlayerName(source)) .. "> " .. "team doesn't have teamData!") end else outputDebugString("<" .. tostring(getPlayerName(source)) .. "> " .. "player isn't logged in") end end addEventHandler("onPlayerWasted", root, onDeath) Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 (edited) 38 minutes ago, IIYAMA said: Thanks for the help, but I think I came up with something else. However, that thing isn't working while it should. Can you guys check it? function spawnAfterLogInOrDeath() local acc = getPlayerAccount(source) if getAccountData(acc, "FirstLoginNow") == true then setTimer( function() if getAccountData(acc, "green") == true then setPlayerTeam(player, getTeamFromName("Special Military Unit")) spawnPlayer (player, -176.84535, 996.75055, 23.63281, 180, 287, 0) end if getAccountData(acc, "blue") == true then setPlayerTeam(player, getTeamFromName("People's Protection Power")) spawnPlayer (player, -176.84535, 996.75055, 23.63281, 180, 282, 0) end if getAccountData(acc, "red") == true then setPlayerTeam(player, getTeamFromName("Ghost Mercenaries")) spawnPlayer (player, -176.84535, 996.75055, 23.63281, 180, 285, 0) end end, 3000, 1) end end addEventHandler("onPlayerLogin", getRootElement(), spawnAfterLogInOrDeath) addEventHandler("onPlayerWasted", getRootElement(), spawnAfterLogInOrDeath) It says ''bad argument @ spawnplayer AND setPlayerTeam (expected player at argument 1, got nil)'' I tried player, thePlayer and source, yet nothing worked. Edited April 14, 2017 by marty000123 Link to comment
AE. Posted April 14, 2017 Share Posted April 14, 2017 (edited) 34 minutes ago, marty000123 said: Thanks for the help, but I think I came up with something else. However, that thing isn't working while it should. Can you guys check it? It says ''bad argument @ spawnplayer AND setPlayerTeam (expected player at argument 1, got nil)'' I tried player, thePlayer and source, yet nothing worked. function spawnAfterLogInOrDeath(player) + split the events don't make it in the same functions Edited April 14, 2017 by 3laa33 Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 (edited) 26 minutes ago, 3laa33 said: function spawnAfterLogInOrDeath(player) + split the events don't make it in the same functions This is what I got now: function spawnAfterDeathOrLogin(player) local acc = getPlayerAccount(source) if getAccountData(acc, "FirstLoginNow") == true then setTimer( function() if getAccountData(acc, "green") == true then setPlayerTeam(player, getTeamFromName("Special Military Unit")) spawnPlayer (player, 235.47963, 1872.47766, 11.46094, 180, 287, 0) triggerClientEvent("class", player) end if getAccountData(acc, "blue") == true then setPlayerTeam(player, getTeamFromName("People's Protection Power")) spawnPlayer (player, -176.84535, 996.75055, 23.63281, 180, 282, 0) triggerClientEvent("class", player) end if getAccountData(acc, "red") == true then setPlayerTeam(player, getTeamFromName("Ghost Mercenaries")) spawnPlayer (player, -551.11359, 2593.78394, 53.93478, 180, 285, 0) triggerClientEvent("class", player) end end, 3000, 1) end end addEventHandler("onPlayerWasted", getRootElement(), spawnAfterDeathOrLogin) addEventHandler("onPlayerLogin", getRootElement(), spawnAfterDeathOrLogin) It still doesn't work. It gives another warning now: bad argument @ spawnPlayer AND setPlayerTeam AND triggerClientEvent (expected player at argument 1 (or 2), got number '1') Edited April 14, 2017 by marty000123 Link to comment
AE. Posted April 14, 2017 Share Posted April 14, 2017 try source and split both of the events ! Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 7 minutes ago, 3laa33 said: try source and split both of the events ! That didn't work. Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 5 minutes ago, 3laa33 said: did you split the events? Yes Link to comment
marty000123 Posted April 14, 2017 Author Share Posted April 14, 2017 (edited) 14 minutes ago, 3laa33 said: show me Trust me, I did exactly that and it didnt work. (i split the script into 6, 3 colors when you die and 3 colors when you login, same elements) Now for some reason the warning changed to: ad argument @ spawnPlayer AND setPlayerTeam AND triggerClientEvent (expected player at argument 1 (or 2), got number '42') So instead of ''1'', it shows ''42'' meaning that the number changes, why I don't know. Not sure why it doesn't just pick player. Edited April 14, 2017 by marty000123 Link to comment
AE. Posted April 14, 2017 Share Posted April 14, 2017 (edited) different functions? i see the problem is from the timer setTimer( function(pp) try this and replace player with pp Edited April 14, 2017 by 3laa33 Link to comment
Gordon_G Posted April 14, 2017 Share Posted April 14, 2017 setTimer( function(player) -- [...] end, 3000, 1, player) 1 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