Jump to content

Problem saving team


Shux

Recommended Posts

Hi, I have this code, but the problem is it doesn't save the player's team , can someone help please? Thank you ! ^_^

function onQuit () 
    local account = getPlayerAccount(source) 
    if account and not (isGuestAccount (account)) then 
    local x,y,z = getElementPosition (source) 
    local occupation = getElementData ( source, "Occupation" ) 
        setAccountData (account, "myCash", tostring (getPlayerMoney (source))) 
        setAccountData (account, "posX", x) 
        setAccountData (account, "posY", y) 
        setAccountData (account, "posZ", z) 
        setAccountData (account, "Occupation", occupation ) 
        setAccountData (account, "theSkin", tostring (getPedSkin (source))) 
        setAccountData (account, "theInt", getElementInterior (source)) 
        setAccountData (account, "theDim", getElementDimension (source)) 
        setAccountData (account, "theWep0", getPedWeapon (source, 0)) 
        setAccountData (account, "theWep1", getPedWeapon (source, 1)) 
        setAccountData (account, "theWep2", getPedWeapon (source, 2)) 
        setAccountData (account, "theWep3", getPedWeapon (source, 3)) 
        setAccountData (account, "theWep4", getPedWeapon (source, 4)) 
        setAccountData (account, "theWep5", getPedWeapon (source, 5)) 
        setAccountData (account, "theWep6", getPedWeapon (source, 6)) 
        setAccountData (account, "theWep7", getPedWeapon (source, 7)) 
        setAccountData (account, "theWep8", getPedWeapon (source, 8)) 
        setAccountData (account, "theWep9", getPedWeapon (source, 9)) 
        setAccountData (account, "theWep10", getPedWeapon (source, 10)) 
        setAccountData (account, "theWep11", getPedWeapon (source, 11)) 
        setAccountData (account, "theWep12", getPedWeapon (source, 12)) 
        setAccountData (account, "theAmmo0", getPedTotalAmmo (source, 0)) 
        setAccountData (account, "theAmmo1", getPedTotalAmmo (source, 1)) 
        setAccountData (account, "theAmmo2", getPedTotalAmmo (source, 2)) 
        setAccountData (account, "theAmmo3", getPedTotalAmmo (source, 3)) 
        setAccountData (account, "theAmmo4", getPedTotalAmmo (source, 4)) 
        setAccountData (account, "theAmmo5", getPedTotalAmmo (source, 5)) 
        setAccountData (account, "theAmmo6", getPedTotalAmmo (source, 6)) 
        setAccountData (account, "theAmmo7", getPedTotalAmmo (source, 7)) 
        setAccountData (account, "theAmmo8", getPedTotalAmmo (source, 8)) 
        setAccountData (account, "theAmmo9", getPedTotalAmmo (source, 9)) 
        setAccountData (account, "theAmmo10", getPedTotalAmmo (source, 10)) 
        setAccountData (account, "theAmmo11", getPedTotalAmmo (source, 11)) 
        setAccountData (account, "theAmmo12", getPedTotalAmmo (source, 12)) 
        local team = getPlayerTeam(source) 
    if (team) and not isGuestAccount(account) then 
        setAccountData(account, "team", getTeamName(team)) 
        
    end 
end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
function assigntheteam (old, acc) 
    local acc = getPlayerAccount(source) 
    local firstTime = getAccountData(acc, 'firstTime') 
    local Unemployed = getTeamFromName ( "Unemployed" ) 
    if ( Unemployed ) then 
    if not firstTime then 
        setPlayerTeam(source, Unemployed) 
        spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) 
        fadeCamera(source, true) 
        setPlayerMoney ( source, 2000 ) 
        setCameraTarget(source, source) 
        setAccountData(acc, 'firstTime', 'true') 
        setElementData ( source, "Occupation", "Unemployed" ) 
        giveWeapon ( source, 23, 200 ) 
        giveWeapon ( source, 25, 200 ) 
    else 
        local playerMoney = getAccountData (acc, "myCash") 
        local playerSkin = getAccountData (acc, "theSkin") 
        local playerInt = getAccountData (acc, "theInt") 
        local playerDim = getAccountData (acc, "theDim") 
        local playerX = getAccountData (acc, "posX") 
        local playerY = getAccountData (acc, "posY") 
        local playerZ = getAccountData (acc, "posZ") 
        local team = getAccountData (acc, "team") 
        local playerWeaponID0 = getAccountData (acc, "theWep0") 
      local playerWeaponID1 = getAccountData (acc, "theWep1") 
      local playerWeaponID2 = getAccountData (acc, "theWep2") 
      local playerWeaponID3 = getAccountData (acc, "theWep3") 
      local playerWeaponID4 = getAccountData (acc, "theWep4") 
      local playerWeaponID5 = getAccountData (acc, "theWep5") 
      local playerWeaponID6 = getAccountData (acc, "theWep6") 
      local playerWeaponID7 = getAccountData (acc, "theWep7") 
      local playerWeaponID8 = getAccountData (acc, "theWep8") 
      local playerOccupation = getAccountData (acc, "Occupation" ) 
      local playerWeaponID9 = getAccountData (acc, "theWep9") 
      local playerWeaponID10 = getAccountData (acc, "theWep10") 
      local playerWeaponID11 = getAccountData (acc, "theWep11") 
      local playerWeaponID12 = getAccountData (acc, "theWep12") 
      local playerWeaponAmmo0 = getAccountData (acc, "theAmmo0") 
      local playerWeaponAmmo1 = getAccountData (acc, "theAmmo1") 
      local playerWeaponAmmo2 = getAccountData (acc, "theAmmo2") 
      local playerWeaponAmmo3 = getAccountData (acc, "theAmmo3") 
      local playerWeaponAmmo4 = getAccountData (acc, "theAmmo4") 
      local playerWeaponAmmo5 = getAccountData (acc, "theAmmo5") 
      local playerWeaponAmmo6 = getAccountData (acc, "theAmmo6") 
      local playerWeaponAmmo7 = getAccountData (acc, "theAmmo7") 
      local playerWeaponAmmo8 = getAccountData (acc, "theAmmo8") 
      local playerWeaponAmmo9 = getAccountData (acc, "theAmmo9") 
      local playerWeaponAmmo10 = getAccountData (acc, "theAmmo10") 
      local playerWeaponAmmo11 = getAccountData (acc, "theAmmo11") 
      local playerWeaponAmmo12 = getAccountData (acc, "theAmmo12") 
        setPlayerMoney (source, tonumber(playerMoney)) 
        spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, playerInt, playerDim) 
        giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) 
      giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) 
      giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) 
      giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) 
      giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) 
      giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) 
      giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) 
      giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) 
      giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) 
      giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) 
      giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) 
      giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) 
      giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) 
      setElementData ( source, "Occupation", playerOccupation ) 
      setCameraTarget(source) 
        local skin = getAccountData(acc,"skin") 
    if (skin) then 
    setElementModel(source, skin) 
    end 
    if getElementModel(source) == 0 then 
    for i=1,16 do 
    local typeclothes = getAccountData(acc,"clothes "..tonumber(i).."") 
    local textclothes = getAccountData(acc,"textclothes "..tonumber(i).."") 
    local modclothes = getAccountData(acc,"modclothes "..tonumber(i).."") 
    addPedClothes (source,tostring(textclothes),tostring(modclothes),tonumber(typeSelected)) 
        -- FOR TEAM 
        if (team) and getTeamFromName(team) then 
        setPlayerTeam(source, team) 
        -- 
        fadeCamera(source, true) 
    end 
 end 
end 
end 
end 
end 
addEvent ( "IfNewPlayerJoin", true ) 
addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) 
addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam) 

Edited by Guest
Link to comment

its code=lua (Obiously remind the []), and close with /code

  
function onQuit () 
    local account = getPlayerAccount(source) 
    if account and not (isGuestAccount (account)) then 
    local x,y,z = getElementPosition (source) 
    local occupation = getElementData ( source, "Occupation" ) 
        setAccountData (account, "myCash", tostring (getPlayerMoney (source))) 
        setAccountData (account, "posX", x) 
        setAccountData (account, "posY", y) 
        setAccountData (account, "posZ", z) 
        setAccountData (account, "Occupation", occupation ) 
        setAccountData (account, "theSkin", tostring (getPedSkin (source))) 
        setAccountData (account, "theInt", getElementInterior (source)) 
        setAccountData (account, "theDim", getElementDimension (source)) 
        setAccountData (account, "theWep0", getPedWeapon (source, 0)) 
        setAccountData (account, "theWep1", getPedWeapon (source, 1)) 
        setAccountData (account, "theWep2", getPedWeapon (source, 2)) 
        setAccountData (account, "theWep3", getPedWeapon (source, 3)) 
        setAccountData (account, "theWep4", getPedWeapon (source, 4)) 
        setAccountData (account, "theWep5", getPedWeapon (source, 5)) 
        setAccountData (account, "theWep6", getPedWeapon (source, 6)) 
        setAccountData (account, "theWep7", getPedWeapon (source, 7)) 
        setAccountData (account, "theWep8", getPedWeapon (source, 8)) 
        setAccountData (account, "theWep9", getPedWeapon (source, 9)) 
        setAccountData (account, "theWep10", getPedWeapon (source, 10)) 
        setAccountData (account, "theWep11", getPedWeapon (source, 11)) 
        setAccountData (account, "theWep12", getPedWeapon (source, 12)) 
        setAccountData (account, "theAmmo0", getPedTotalAmmo (source, 0)) 
        setAccountData (account, "theAmmo1", getPedTotalAmmo (source, 1)) 
        setAccountData (account, "theAmmo2", getPedTotalAmmo (source, 2)) 
        setAccountData (account, "theAmmo3", getPedTotalAmmo (source, 3)) 
        setAccountData (account, "theAmmo4", getPedTotalAmmo (source, 4)) 
        setAccountData (account, "theAmmo5", getPedTotalAmmo (source, 5)) 
        setAccountData (account, "theAmmo6", getPedTotalAmmo (source, 6)) 
        setAccountData (account, "theAmmo7", getPedTotalAmmo (source, 7)) 
        setAccountData (account, "theAmmo8", getPedTotalAmmo (source, 8)) 
        setAccountData (account, "theAmmo9", getPedTotalAmmo (source, 9)) 
        setAccountData (account, "theAmmo10", getPedTotalAmmo (source, 10)) 
        setAccountData (account, "theAmmo11", getPedTotalAmmo (source, 11)) 
        setAccountData (account, "theAmmo12", getPedTotalAmmo (source, 12)) 
        local team = getPlayerTeam(source) 
    if (team) and not isGuestAccount(account) then 
        setAccountData(account, "team", getTeamName(team)) 
        
    end 
end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
function assigntheteam (old, acc) 
    local acc = getPlayerAccount(source) 
    local firstTime = getAccountData(acc, 'firstTime') 
    local Unemployed = getTeamFromName ( "Unemployed" ) 
    if ( Unemployed ) then 
    if not firstTime then 
        setPlayerTeam(source, Unemployed) 
        spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) 
        fadeCamera(source, true) 
        setPlayerMoney ( source, 2000 ) 
        setCameraTarget(source, source) 
        setAccountData(acc, 'firstTime', 'true') 
        setElementData ( source, "Occupation", "Unemployed" ) 
        giveWeapon ( source, 23, 200 ) 
        giveWeapon ( source, 25, 200 ) 
    else 
        local playerMoney = getAccountData (acc, "myCash") 
        local playerSkin = getAccountData (acc, "theSkin") 
        local playerInt = getAccountData (acc, "theInt") 
        local playerDim = getAccountData (acc, "theDim") 
        local playerX = getAccountData (acc, "posX") 
        local playerY = getAccountData (acc, "posY") 
        local playerZ = getAccountData (acc, "posZ") 
        local team = getAccountData (acc, "team") 
        local playerWeaponID0 = getAccountData (acc, "theWep0") 
      local playerWeaponID1 = getAccountData (acc, "theWep1") 
      local playerWeaponID2 = getAccountData (acc, "theWep2") 
      local playerWeaponID3 = getAccountData (acc, "theWep3") 
      local playerWeaponID4 = getAccountData (acc, "theWep4") 
      local playerWeaponID5 = getAccountData (acc, "theWep5") 
      local playerWeaponID6 = getAccountData (acc, "theWep6") 
      local playerWeaponID7 = getAccountData (acc, "theWep7") 
      local playerWeaponID8 = getAccountData (acc, "theWep8") 
      local playerOccupation = getAccountData (acc, "Occupation" ) 
      local playerWeaponID9 = getAccountData (acc, "theWep9") 
      local playerWeaponID10 = getAccountData (acc, "theWep10") 
      local playerWeaponID11 = getAccountData (acc, "theWep11") 
      local playerWeaponID12 = getAccountData (acc, "theWep12") 
      local playerWeaponAmmo0 = getAccountData (acc, "theAmmo0") 
      local playerWeaponAmmo1 = getAccountData (acc, "theAmmo1") 
      local playerWeaponAmmo2 = getAccountData (acc, "theAmmo2") 
      local playerWeaponAmmo3 = getAccountData (acc, "theAmmo3") 
      local playerWeaponAmmo4 = getAccountData (acc, "theAmmo4") 
      local playerWeaponAmmo5 = getAccountData (acc, "theAmmo5") 
      local playerWeaponAmmo6 = getAccountData (acc, "theAmmo6") 
      local playerWeaponAmmo7 = getAccountData (acc, "theAmmo7") 
      local playerWeaponAmmo8 = getAccountData (acc, "theAmmo8") 
      local playerWeaponAmmo9 = getAccountData (acc, "theAmmo9") 
      local playerWeaponAmmo10 = getAccountData (acc, "theAmmo10") 
      local playerWeaponAmmo11 = getAccountData (acc, "theAmmo11") 
      local playerWeaponAmmo12 = getAccountData (acc, "theAmmo12") 
        setPlayerMoney (source, tonumber(playerMoney)) 
        spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, playerInt, playerDim) 
        giveWeapon(source, playerWeaponID0, playerWeaponAmmo0, true) 
      giveWeapon(source, playerWeaponID1, playerWeaponAmmo1, false) 
      giveWeapon(source, playerWeaponID2, playerWeaponAmmo2, false) 
      giveWeapon(source, playerWeaponID3, playerWeaponAmmo3, false) 
      giveWeapon(source, playerWeaponID4, playerWeaponAmmo4, false) 
      giveWeapon(source, playerWeaponID5, playerWeaponAmmo5, false) 
      giveWeapon(source, playerWeaponID6, playerWeaponAmmo6, false) 
      giveWeapon(source, playerWeaponID7, playerWeaponAmmo7, false) 
      giveWeapon(source, playerWeaponID8, playerWeaponAmmo8, false) 
      giveWeapon(source, playerWeaponID9, playerWeaponAmmo9, false) 
      giveWeapon(source, playerWeaponID10, playerWeaponAmmo10, false) 
      giveWeapon(source, playerWeaponID11, playerWeaponAmmo11, false) 
      giveWeapon(source, playerWeaponID12, playerWeaponAmmo12, false) 
      setElementData ( source, "Occupation", playerOccupation ) 
      setCameraTarget(source) 
        local skin = getAccountData(acc,"skin") 
    if (skin) then 
    setElementModel(source, skin) 
    end 
    if getElementModel(source) == 0 then 
    for i=1,16 do 
    local typeclothes = getAccountData(acc,"clothes "..tonumber(i).."") 
    local textclothes = getAccountData(acc,"textclothes "..tonumber(i).."") 
    local modclothes = getAccountData(acc,"modclothes "..tonumber(i).."") 
    addPedClothes (source,tostring(textclothes),tostring(modclothes),tonumber(typeSelected)) 
        -- FOR TEAM 
        if (team) and getTeamFromName(team) then 
        setPlayerTeam(source, team) 
        -- 
        fadeCamera(source, true) 
    end 
 end 
end 
end 
end 
end 
addEvent ( "IfNewPlayerJoin", true ) 
addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) 
addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...