Reezmi Posted July 16, 2013 Share Posted July 16, 2013 Why is it giving me Bad argument @ 'getTeamColor' error I dont get it.. function spawningAfterLogin () local playerAccount = getPlayerAccount(source) local playerX = getAccountData (playerAccount, "LastPositionX") local playerY = getAccountData (playerAccount, "LastPositionY") local playerZ = getAccountData (playerAccount, "LastPositionZ") local playerSkin = getAccountData (playerAccount, "Skin") local playerHealth = getAccountData (playerAccount, "Health") local playerArmor = getAccountData (playerAccount, "Armor") local playerMoney = getAccountData (playerAccount, "Money") local playerInterior = getAccountData (playerAccount, "Interior") local playerDimension = getAccountData (playerAccount, "Dimension") local playerWanted = getAccountData (playerAccount, "Wanted") local playerJob = getAccountData (playerAccount, "Job") local r, g, b = getTeamColor(getPlayerTeam(source)) spawnPlayer (source, playerX,playerY,playerZ, -0, playerSkin, 0, 0, nil) fadeCamera(source, true, 3) setPlayerMoney (source, playerMoney) setElementDimension (source, playerDimension) setPlayerTeam (source, getTeamFromName (playerJob)) createBlipAttachedTo ( source, 0, 2, r, g, b, 0, 65535, root ) setElementInterior (source, playerInterior) setTimer (setElementHealth, 500, 1, source, playerHealth) setTimer (setPedArmor, 500, 1, source, playerArmor) setTimer (setPlayerWantedLevel, 500, 1, source, playerWanted) setCameraTarget (source, source) showCustomHudComponent (source,"all",true) showPlayerHudComponent ( source, "radar", true ) end addEvent ( "onLoginSpawn", true ) addEventHandler ( "onLoginSpawn", root, spawningAfterLogin ) Link to comment
Castillo Posted July 16, 2013 Share Posted July 16, 2013 Well, maybe you haven't got a team? Link to comment
Reezmi Posted July 16, 2013 Author Share Posted July 16, 2013 I have team and I can also see that im added in tab team list Link to comment
Castillo Posted July 16, 2013 Share Posted July 16, 2013 Show me how you trigger: "onLoginSpawn", I know you do it from the client side, show me the code. Link to comment
Reezmi Posted July 16, 2013 Author Share Posted July 16, 2013 No, i have it from server-side function onLogin ( player, user, pass ) local account = getAccount ( user, pass ) if ( account ~= false ) then if ( not isGuestAccount ( account ) ) then logOut ( player ) end if (logIn ( player, account, pass ) == true) then fadeCamera(player, false, 2) setTimer (triggerEvent, 3000, 1, "onLoginSpawn", player) triggerClientEvent ( player, "hideLoginWindow", getRootElement()) else outputChatBox ( "Error logging in", player, 255, 255, 0 ) end else outputChatBox ( "Wrong username or password", player, 255, 255, 0 ) end end addEvent( "onLogin", true ) addEventHandler( "onLogin", getRootElement(), onLogin ) Link to comment
Castillo Posted July 16, 2013 Share Posted July 16, 2013 Before: local r, g, b = getTeamColor(getPlayerTeam(source)) put this: if ( not getPlayerTeam ( source ) ) then outputChatBox ( "NO TEAM" ) end Link to comment
Reezmi Posted July 16, 2013 Author Share Posted July 16, 2013 Looks like it doesnt find team I'll try to clean db Link to comment
Reezmi Posted July 16, 2013 Author Share Posted July 16, 2013 Cleared db. Registered again and result is same. Maybe im saving teams incorrectly? And yes teams are being shown in userdata. function spawningAfterRegister ( ) local r, g, b = getTeamColor(getPlayerTeam(source)) local Skins = {184, 188, 170, 101, 93, 88, 56, 53, 48, 47, 46, 22, 20, 21, 7} spawnPlayer (source, -1633.2635498047,1418.2386474609,7.1875, -0, Skins[math.random(1, #Skins)], 0, 0, nil) fadeCamera(source, true, 3) setCameraTarget (source, source) setPlayerTeam(source, getTeamFromName ( "Civilians" )) setTimer (createBlipAttachedTo, 500, 1, source, 0, 2, r, g, b, 0, 65535, root) triggerEvent ( "onUpdatePlayerData", source ) showCustomHudComponent (source,"all",true) showPlayerHudComponent ( source, "radar", true ) end addEvent ( "onRegisterSpawn", true ) addEventHandler ( "onRegisterSpawn", root, spawningAfterRegister ) function updateData() local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then local x,y,z = getElementPosition (source) setAccountData (playerAccount, "LastPositionX", x) setAccountData (playerAccount, "LastPositionY", y) setAccountData (playerAccount, "LastPositionZ", z) setAccountData (playerAccount, "Skin", tostring (getPedSkin (source))) setAccountData (playerAccount, "Health", tostring (getElementHealth (source))) setAccountData (playerAccount, "Armor", tostring (getPedArmor (source))) setAccountData (playerAccount, "Money", tostring (getPlayerMoney (source))) setAccountData (playerAccount, "Interior", getElementInterior (source)) setAccountData (playerAccount, "Dimension", getElementDimension (source)) setAccountData (playerAccount, "Wanted", getPlayerWantedLevel (source)) setAccountData (playerAccount, "Job", getTeamName(getPlayerTeam ( source ))) outputDebugString("Saving stats", 3) end end addEvent ( "onUpdatePlayerData", true ) addEventHandler( "onUpdatePlayerData", root, updateData) Link to comment
Castillo Posted July 16, 2013 Share Posted July 16, 2013 function spawningAfterLogin () local playerAccount = getPlayerAccount(source) local playerX = getAccountData (playerAccount, "LastPositionX") local playerY = getAccountData (playerAccount, "LastPositionY") local playerZ = getAccountData (playerAccount, "LastPositionZ") local playerSkin = getAccountData (playerAccount, "Skin") local playerHealth = getAccountData (playerAccount, "Health") local playerArmor = getAccountData (playerAccount, "Armor") local playerMoney = getAccountData (playerAccount, "Money") local playerInterior = getAccountData (playerAccount, "Interior") local playerDimension = getAccountData (playerAccount, "Dimension") local playerWanted = getAccountData (playerAccount, "Wanted") local playerJob = getAccountData (playerAccount, "Job") local team = getTeamFromName ( playerJob ) if ( team ) then r, g, b = getTeamColor ( team ) end spawnPlayer (source, playerX,playerY,playerZ, -0, playerSkin, 0, 0, nil) fadeCamera(source, true, 3) setPlayerMoney (source, playerMoney) setElementDimension (source, playerDimension) setPlayerTeam (source, team) createBlipAttachedTo ( source, 0, 2, r or 255, g or 255, b or 255, 0, 65535, root ) setElementInterior (source, playerInterior) setTimer (setElementHealth, 500, 1, source, playerHealth) setTimer (setPedArmor, 500, 1, source, playerArmor) setTimer (setPlayerWantedLevel, 500, 1, source, playerWanted) setCameraTarget (source, source) showCustomHudComponent (source,"all",true) showPlayerHudComponent ( source, "radar", true ) end addEvent ( "onLoginSpawn", true ) addEventHandler ( "onLoginSpawn", root, spawningAfterLogin ) Link to comment
Reezmi Posted July 16, 2013 Author Share Posted July 16, 2013 ty so much it works now 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