Jump to content

Skin Selector problem


xeon17

Recommended Posts

So , the problem is pretty simple i save the data of players when they quit or the resource stop , data such as position,skin,weapons,dimension etcetc. But the problem is , if a new player create a account , he doesn't have any data so he will be spawned at x,y,z (0,0,0) i wanted to create that he will be spawned on a custom location, with custom weapons. But it doesn't work , the player is still spawned at 0.0,0. I don't know what's the problem , also there aren't errors on debugscript3.

This is my code when i'm spawning the player.

function SpawnPlayer(thePlayer,skin,r,g,b) 
    local theCurrentAccount = getPlayerAccount(thePlayer) 
    local accountData = getAccountData (theCurrentAccount, "funmodev2-money") 
            if (accountData) then 
              local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") 
              local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") 
              local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") 
              local playerR = getAccountData (theCurrentAccount, "funmodev2-R") 
              local playerG = getAccountData (theCurrentAccount, "funmodev2-G") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerX = getAccountData (theCurrentAccount, "funmodev2-x") 
              local playerY = getAccountData (theCurrentAccount, "funmodev2-y") 
              local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") 
              if not (playerX or playerY or playerZ) then 
              spawnPlayer(source,1459.64014,-1643.40723, 438.94131,90.0,skin,0,0) 
              giveWeapon(source,46,1,true) 
              setCameraTarget (source, source) 
              setPlayerMoney(source,2500)  
              return end 
              local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") 
              local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") 
              local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") 
              local playerWeaponID0 = getAccountData (theCurrentAccount, "funmodev2-weaponID0") 
              local playerWeaponID1 = getAccountData (theCurrentAccount, "funmodev2-weaponID1") 
              local playerWeaponID2 = getAccountData (theCurrentAccount, "funmodev2-weaponID2") 
              local playerWeaponID3 = getAccountData (theCurrentAccount, "funmodev2-weaponID3") 
              local playerWeaponID4 = getAccountData (theCurrentAccount, "funmodev2-weaponID4") 
              local playerWeaponID5 = getAccountData (theCurrentAccount, "funmodev2-weaponID5") 
              local playerWeaponID6 = getAccountData (theCurrentAccount, "funmodev2-weaponID6") 
              local playerWeaponID7 = getAccountData (theCurrentAccount, "funmodev2-weaponID7") 
              local playerWeaponID8 = getAccountData (theCurrentAccount, "funmodev2-weaponID8") 
              local playerWeaponID9 = getAccountData (theCurrentAccount, "funmodev2-weaponID9") 
              local playerWeaponID10 = getAccountData (theCurrentAccount, "funmodev2-weaponID10") 
              local playerWeaponID11 = getAccountData (theCurrentAccount, "funmodev2-weaponID11") 
              local playerWeaponID12 = getAccountData (theCurrentAccount, "funmodev2-weaponID12") 
              local playerWeaponAmmo0 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo0") 
              local playerWeaponAmmo1 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo1") 
              local playerWeaponAmmo2 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo2") 
              local playerWeaponAmmo3 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo3") 
              local playerWeaponAmmo4 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo4") 
              local playerWeaponAmmo5 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo5") 
              local playerWeaponAmmo6 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo6") 
              local playerWeaponAmmo7 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo7") 
              local playerWeaponAmmo8 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo8") 
              local playerWeaponAmmo9 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo9") 
              local playerWeaponAmmo10 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo10") 
              local playerWeaponAmmo11 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo11") 
              local playerWeaponAmmo12 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo12") 
              spawnPlayer ( thePlayer, playerX, playerY, playerZ + 2, 90.0, skin ,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) 
        end 
    setCameraTarget (source, source) 
    setPlayerMoney(source,accountData) 
    playerSkin[source] = {skin,r,g,b} 
    setElementData(source,"Score",0) 
    setPlayerNametagShowing ( source, false) 
end 
addEvent( "onClientWantsToSpawn", true ) 
addEventHandler( "onClientWantsToSpawn", getRootElement(), SpawnPlayer ) 

Link to comment

I think you should add another SpawnPlayer function between line 3 and line 4.

function SpawnPlayer(thePlayer,skin,r,g,b) 
    local theCurrentAccount = getPlayerAccount(thePlayer) 
    local accountData = getAccountData (theCurrentAccount, "funmodev2-money") 
    spawnPlayer ( thePlayer, float_x, float_y, float_z, float_rot, skin_model, interior, dimension  ) --- here you put some custom values 
            if (accountData) then 
              local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") 
              local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") 
              local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") 
              local playerR = getAccountData (theCurrentAccount, "funmodev2-R") 
              local playerG = getAccountData (theCurrentAccount, "funmodev2-G") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerX = getAccountData (theCurrentAccount, "funmodev2-x") 
              local playerY = getAccountData (theCurrentAccount, "funmodev2-y") 
              local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") 
              if not (playerX or playerY or playerZ) then 
              spawnPlayer(source,1459.64014,-1643.40723, 438.94131,90.0,skin,0,0) 
              giveWeapon(source,46,1,true) 
              setCameraTarget (source, source) 
              setPlayerMoney(source,2500) 
              return end 
              local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") 
              local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") 
              local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") 
              local playerWeaponID0 = getAccountData (theCurrentAccount, "funmodev2-weaponID0") 
              local playerWeaponID1 = getAccountData (theCurrentAccount, "funmodev2-weaponID1") 
              local playerWeaponID2 = getAccountData (theCurrentAccount, "funmodev2-weaponID2") 
              local playerWeaponID3 = getAccountData (theCurrentAccount, "funmodev2-weaponID3") 
              local playerWeaponID4 = getAccountData (theCurrentAccount, "funmodev2-weaponID4") 
              local playerWeaponID5 = getAccountData (theCurrentAccount, "funmodev2-weaponID5") 
              local playerWeaponID6 = getAccountData (theCurrentAccount, "funmodev2-weaponID6") 
              local playerWeaponID7 = getAccountData (theCurrentAccount, "funmodev2-weaponID7") 
              local playerWeaponID8 = getAccountData (theCurrentAccount, "funmodev2-weaponID8") 
              local playerWeaponID9 = getAccountData (theCurrentAccount, "funmodev2-weaponID9") 
              local playerWeaponID10 = getAccountData (theCurrentAccount, "funmodev2-weaponID10") 
              local playerWeaponID11 = getAccountData (theCurrentAccount, "funmodev2-weaponID11") 
              local playerWeaponID12 = getAccountData (theCurrentAccount, "funmodev2-weaponID12") 
              local playerWeaponAmmo0 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo0") 
              local playerWeaponAmmo1 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo1") 
              local playerWeaponAmmo2 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo2") 
              local playerWeaponAmmo3 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo3") 
              local playerWeaponAmmo4 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo4") 
              local playerWeaponAmmo5 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo5") 
              local playerWeaponAmmo6 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo6") 
              local playerWeaponAmmo7 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo7") 
              local playerWeaponAmmo8 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo8") 
              local playerWeaponAmmo9 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo9") 
              local playerWeaponAmmo10 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo10") 
              local playerWeaponAmmo11 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo11") 
              local playerWeaponAmmo12 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo12") 
              spawnPlayer ( thePlayer, playerX, playerY, playerZ + 2, 90.0, skin ,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) 
        end 
    setCameraTarget (source, source) 
    setPlayerMoney(source,accountData) 
    playerSkin[source] = {skin,r,g,b} 
    setElementData(source,"Score",0) 
    setPlayerNametagShowing ( source, false) 
end 
addEvent( "onClientWantsToSpawn", true ) 
addEventHandler( "onClientWantsToSpawn", getRootElement(), SpawnPlayer ) 
  

Link to comment

Thanks for trying to help , but this will spawn the player every time on this custom location , and not on the location where he quit , so it would pretty destroy everything.

Here is the whole server side ,

function onQuit () 
        local account = getPlayerAccount (source) 
          if ( account ) then 
              local x,y,z = getElementPosition (source) 
              setAccountData (account, "funmodev2-money", getPlayerMoney (source)) 
              setAccountData (account, "funmodev2-skin", getElementModel (source)) 
              setAccountData (account, "funmodev2-health", getElementHealth (source)) 
              setAccountData (account, "funmodev2-armor", getPedArmor (source)) 
              setAccountData (account, "funmodev2-R", r) 
              setAccountData (account, "funmodev2-G", g) 
              setAccountData (account, "funmodev2-B", b) 
              setAccountData (account, "funmodev2-x", x) 
              setAccountData (account, "funmodev2-y", y) 
              setAccountData (account, "funmodev2-z", z) 
              setAccountData (account, "funmodev2-int", getElementInterior (source)) 
              setAccountData (account, "funmodev2-dim", getElementDimension (source)) 
              setAccountData (account, "funmodev2-wantedlevel", getPlayerWantedLevel (source)) 
              setAccountData (account, "funmodev2-weaponID0", getPedWeapon (source, 0)) 
              setAccountData (account, "funmodev2-weaponID1", getPedWeapon (source, 1)) 
              setAccountData (account, "funmodev2-weaponID2", getPedWeapon (source, 2)) 
              setAccountData (account, "funmodev2-weaponID3", getPedWeapon (source, 3)) 
              setAccountData (account, "funmodev2-weaponID4", getPedWeapon (source, 4)) 
              setAccountData (account, "funmodev2-weaponID5", getPedWeapon (source, 5)) 
              setAccountData (account, "funmodev2-weaponID6", getPedWeapon (source, 6)) 
              setAccountData (account, "funmodev2-weaponID7", getPedWeapon (source, 7)) 
              setAccountData (account, "funmodev2-weaponID8", getPedWeapon (source,8)) 
              setAccountData (account, "funmodev2-weaponID9", getPedWeapon (source,9)) 
              setAccountData (account, "funmodev2-weaponID10", getPedWeapon (source, 10)) 
              setAccountData (account, "funmodev2-weaponID11", getPedWeapon (source, 11)) 
              setAccountData (account, "funmodev2-weaponID12", getPedWeapon (source, 12)) 
              setAccountData (account, "funmodev2-weaponAmmo0", getPedTotalAmmo (source, 0)) 
              setAccountData (account, "funmodev2-weaponAmmo1", getPedTotalAmmo (source, 1)) 
              setAccountData (account, "funmodev2-weaponAmmo2", getPedTotalAmmo (source, 2)) 
              setAccountData (account, "funmodev2-weaponAmmo3", getPedTotalAmmo (source, 3)) 
              setAccountData (account, "funmodev2-weaponAmmo4", getPedTotalAmmo (source, 4)) 
              setAccountData (account, "funmodev2-weaponAmmo5", getPedTotalAmmo (source, 5)) 
              setAccountData (account, "funmodev2-weaponAmmo6", getPedTotalAmmo (source, 6)) 
              setAccountData (account, "funmodev2-weaponAmmo7", getPedTotalAmmo (source, 7)) 
              setAccountData (account, "funmodev2-weaponAmmo8", getPedTotalAmmo (source,8)) 
              setAccountData (account, "funmodev2-weaponAmmo9", getPedTotalAmmo (source, 9)) 
              setAccountData (account, "funmodev2-weaponAmmo10", getPedTotalAmmo (source, 10)) 
              setAccountData (account, "funmodev2-weaponAmmo11", getPedTotalAmmo (source, 11)) 
              setAccountData (account, "funmodev2-weaponAmmo12", getPedTotalAmmo (source, 12)) 
        end 
        end 
        addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
 function onStop (resource) 
              for _, player in ipairs( getElementsByType("players") ) do 
              local account = getPlayerAccount (player) 
              if ( account ) then 
              local x,y,z = getElementPosition (player) 
              setAccountData (account, "funmodev2-money", getPlayerMoney (player)) 
              setAccountData (account, "funmodev2-skin", getElementModel (player)) 
              setAccountData (account, "funmodev2-health", getElementHealth (player)) 
              setAccountData (account, "funmodev2-armor", getPedArmor (player)) 
              setAccountData (account, "funmodev2-R", r) 
              setAccountData (account, "funmodev2-G", g) 
              setAccountData (account, "funmodev2-B", b) 
              setAccountData (account, "funmodev2-x", x) 
              setAccountData (account, "funmodev2-y", y) 
              setAccountData (account, "funmodev2-z", z) 
              setAccountData (account, "funmodev2-int", getElementInterior (player)) 
              setAccountData (account, "funmodev2-dim", getElementDimension (player)) 
              setAccountData (account, "funmodev2-wantedlevel", getPlayerWantedLevel (player)) 
              setAccountData (account, "funmodev2-weaponID0", getPedWeapon (player, 0)) 
              setAccountData (account, "funmodev2-weaponID1", getPedWeapon (player, 1)) 
              setAccountData (account, "funmodev2-weaponID2", getPedWeapon (player, 2)) 
              setAccountData (account, "funmodev2-weaponID3", getPedWeapon (player, 3)) 
              setAccountData (account, "funmodev2-weaponID4", getPedWeapon (player, 4)) 
              setAccountData (account, "funmodev2-weaponID5", getPedWeapon (player, 5)) 
              setAccountData (account, "funmodev2-weaponID6", getPedWeapon (player, 6)) 
              setAccountData (account, "funmodev2-weaponID7", getPedWeapon (player, 7)) 
              setAccountData (account, "funmodev2-weaponID8", getPedWeapon (player,8)) 
              setAccountData (account, "funmodev2-weaponID9", getPedWeapon (player,9)) 
              setAccountData (account, "funmodev2-weaponID10", getPedWeapon (player, 10)) 
              setAccountData (account, "funmodev2-weaponID11", getPedWeapon (player, 11)) 
              setAccountData (account, "funmodev2-weaponID12", getPedWeapon (player, 12)) 
              setAccountData (account, "funmodev2-weaponAmmo0", getPedTotalAmmo (player, 0)) 
              setAccountData (account, "funmodev2-weaponAmmo1", getPedTotalAmmo (player, 1)) 
              setAccountData (account, "funmodev2-weaponAmmo2", getPedTotalAmmo (player, 2)) 
              setAccountData (account, "funmodev2-weaponAmmo3", getPedTotalAmmo (player, 3)) 
              setAccountData (account, "funmodev2-weaponAmmo4", getPedTotalAmmo (player, 4)) 
              setAccountData (account, "funmodev2-weaponAmmo5", getPedTotalAmmo (player, 5)) 
              setAccountData (account, "funmodev2-weaponAmmo6", getPedTotalAmmo (player, 6)) 
              setAccountData (account, "funmodev2-weaponAmmo7", getPedTotalAmmo (player, 7)) 
              setAccountData (account, "funmodev2-weaponAmmo8", getPedTotalAmmo (player, -- s8) -->) 
              setAccountData (account, "funmodev2-weaponAmmo9", getPedTotalAmmo (player, 9)) 
              setAccountData (account, "funmodev2-weaponAmmo10", getPedTotalAmmo (player, 10)) 
              setAccountData (account, "funmodev2-weaponAmmo11", getPedTotalAmmo (player, 11)) 
              setAccountData (account, "funmodev2-weaponAmmo12", getPedTotalAmmo (player, 12)) 
        end 
        end 
        end 
        addEventHandler ("onResourceStop", resourceRoot, onStop) 
  
  
local spawnLocations = { 
{2171.90625, 1392.59765625, 10.8203125}, 
{2265.3674316406, 2398.3068847656, 10.8203125}, 
{2361.689453125, 2070.2077636719, 10.671875}, 
{2087.9260253906, 1448.8768310547, 10.8203125}, 
{2000.55, 1526.25, 14.6171875}, 
{1607.35, 1816.54, 10.82} 
} 
  
  
  
StartMoney = 2500 
CashForKill = 2500 
PayNSprayCost = 100 
  
playerSkin = {} 
Garages = {0,1,2,3,4,5,6,7,8,9,10, 
11,12,13,14,15,16,17,18,19,20, 
21,22,23,24,25,26,27,28,29,30, 
31,32,33,34,35,36,37,38,39,40, 
41,42,43,44,45,46,47,48,49,50, 
51,52,53,54,55,56,57,58,59,60} 
  
  
  
  
function SpawnPlayer(thePlayer,skin,r,g,b) 
    local theCurrentAccount = getPlayerAccount(thePlayer) 
    local accountData = getAccountData (theCurrentAccount, "funmodev2-money") 
              spawnPlayer ( thePlayer,1459.64014,-1643.40723, 438.94131,90.0,skin,0,0  ) --- here you put some custom values 
              giveWeapon(thePlayer,46,1,true) 
              setPlayerMoney(thePlayer,2500) 
              setCameraTarget(thePlayer,thePlayer) 
              if (accountData) then 
              local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") 
              local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") 
              local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") 
              local playerR = getAccountData (theCurrentAccount, "funmodev2-R") 
              local playerG = getAccountData (theCurrentAccount, "funmodev2-G") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerX = getAccountData (theCurrentAccount, "funmodev2-x") 
              local playerY = getAccountData (theCurrentAccount, "funmodev2-y") 
              local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") 
              if not (playerX or playerY or playerZ) then 
              local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") 
              local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") 
              local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") 
              local playerWeaponID0 = getAccountData (theCurrentAccount, "funmodev2-weaponID0") 
              local playerWeaponID1 = getAccountData (theCurrentAccount, "funmodev2-weaponID1") 
              local playerWeaponID2 = getAccountData (theCurrentAccount, "funmodev2-weaponID2") 
              local playerWeaponID3 = getAccountData (theCurrentAccount, "funmodev2-weaponID3") 
              local playerWeaponID4 = getAccountData (theCurrentAccount, "funmodev2-weaponID4") 
              local playerWeaponID5 = getAccountData (theCurrentAccount, "funmodev2-weaponID5") 
              local playerWeaponID6 = getAccountData (theCurrentAccount, "funmodev2-weaponID6") 
              local playerWeaponID7 = getAccountData (theCurrentAccount, "funmodev2-weaponID7") 
              local playerWeaponID8 = getAccountData (theCurrentAccount, "funmodev2-weaponID8") 
              local playerWeaponID9 = getAccountData (theCurrentAccount, "funmodev2-weaponID9") 
              local playerWeaponID10 = getAccountData (theCurrentAccount, "funmodev2-weaponID10") 
              local playerWeaponID11 = getAccountData (theCurrentAccount, "funmodev2-weaponID11") 
              local playerWeaponID12 = getAccountData (theCurrentAccount, "funmodev2-weaponID12") 
              local playerWeaponAmmo0 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo0") 
              local playerWeaponAmmo1 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo1") 
              local playerWeaponAmmo2 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo2") 
              local playerWeaponAmmo3 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo3") 
              local playerWeaponAmmo4 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo4") 
              local playerWeaponAmmo5 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo5") 
              local playerWeaponAmmo6 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo6") 
              local playerWeaponAmmo7 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo7") 
              local playerWeaponAmmo8 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo8") 
              local playerWeaponAmmo9 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo9") 
              local playerWeaponAmmo10 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo10") 
              local playerWeaponAmmo11 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo11") 
              local playerWeaponAmmo12 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo12") 
              spawnPlayer ( thePlayer, playerX, playerY, playerZ + 2, 90.0, skin ,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) 
        end 
    setCameraTarget (source, source) 
    setPlayerMoney(source,accountData) 
    playerSkin[source] = {skin,r,g,b} 
    setElementData(source,"Score",0) 
    setPlayerNametagShowing ( source, false) 
end 
end 
addEvent( "onClientWantsToSpawn", true ) 
addEventHandler( "onClientWantsToSpawn", getRootElement(), SpawnPlayer ) 
  
  
  
  
function PlayerDied(ammo,killer) 
    if killer and getElementType ( killer ) == "player" then 
        setPlayerMoney(killer,getPlayerMoney(killer)+CashForKill) 
        local Score = getElementData(killer,"Score") 
        setElementData(killer,"Score",Score+1) 
    end 
setTimer(PlayerRespawn,1000,1,source) 
end 
addEventHandler("onPlayerWasted",getRootElement(),PlayerDied) 
  
function PlayerRespawn(diedPlayer) 
if not diedPlayer then else 
    toggleAllControls(diedPlayer,true) 
    setPlayerMoney(diedPlayer,StartMoney) 
    local chosenSpawnLocation = math.random(1,#spawnLocations) 
   spawnPlayer(diedPlayer,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3],90,playerSkin[diedPlayer][1]) 
    setCameraTarget (diedPlayer, diedPlayer) 
end 
end 
  
  
--server 
    function a () 
        triggerClientEvent(source,"TriggerClient",getRootElement()) 
 end 
 addEventHandler ( "onPlayerLogin",getRootElement(),a ) 
    
  

I also tried this ,

              if not (playerX or playerY or playerZ) then 
              spawnPlayer(source,1459.64014,-1643.40723, 438.94131,90.0,skin,0,0) 
              giveWeapon(source,46,1,true) 
              setCameraTarget (source, source) 
              setPlayerMoney(source,2500) 
              return end 

but it didn't worked. Please help :|

Link to comment

try this:

function SpawnPlayer(thePlayer,skin,r,g,b) 
    local theCurrentAccount = getPlayerAccount(thePlayer) 
    local accountData = getAccountData (theCurrentAccount, "funmodev2-money") 
            if (accountData) then 
              local playerSkin = getAccountData (theCurrentAccount, "funmodev2-skin") 
              local playerHealth = getAccountData (theCurrentAccount, "funmodev2-health") 
              local playerArmor = getAccountData (theCurrentAccount, "funmodev2-armor") 
              local playerR = getAccountData (theCurrentAccount, "funmodev2-R") 
              local playerG = getAccountData (theCurrentAccount, "funmodev2-G") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerB = getAccountData (theCurrentAccount, "funmodev2-B") 
              local playerX = getAccountData (theCurrentAccount, "funmodev2-x") 
              local playerY = getAccountData (theCurrentAccount, "funmodev2-y") 
              local playerZ = getAccountData (theCurrentAccount, "funmodev2-z") 
              local playerInt = getAccountData (theCurrentAccount, "funmodev2-int") 
              local playerDim = getAccountData (theCurrentAccount, "funmodev2-dim") 
              local playerWanted = getAccountData (theCurrentAccount, "funmodev2-wantedlevel") 
              local playerWeaponID0 = getAccountData (theCurrentAccount, "funmodev2-weaponID0") 
              local playerWeaponID1 = getAccountData (theCurrentAccount, "funmodev2-weaponID1") 
              local playerWeaponID2 = getAccountData (theCurrentAccount, "funmodev2-weaponID2") 
              local playerWeaponID3 = getAccountData (theCurrentAccount, "funmodev2-weaponID3") 
              local playerWeaponID4 = getAccountData (theCurrentAccount, "funmodev2-weaponID4") 
              local playerWeaponID5 = getAccountData (theCurrentAccount, "funmodev2-weaponID5") 
              local playerWeaponID6 = getAccountData (theCurrentAccount, "funmodev2-weaponID6") 
              local playerWeaponID7 = getAccountData (theCurrentAccount, "funmodev2-weaponID7") 
              local playerWeaponID8 = getAccountData (theCurrentAccount, "funmodev2-weaponID8") 
              local playerWeaponID9 = getAccountData (theCurrentAccount, "funmodev2-weaponID9") 
              local playerWeaponID10 = getAccountData (theCurrentAccount, "funmodev2-weaponID10") 
              local playerWeaponID11 = getAccountData (theCurrentAccount, "funmodev2-weaponID11") 
              local playerWeaponID12 = getAccountData (theCurrentAccount, "funmodev2-weaponID12") 
              local playerWeaponAmmo0 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo0") 
              local playerWeaponAmmo1 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo1") 
              local playerWeaponAmmo2 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo2") 
              local playerWeaponAmmo3 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo3") 
              local playerWeaponAmmo4 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo4") 
              local playerWeaponAmmo5 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo5") 
              local playerWeaponAmmo6 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo6") 
              local playerWeaponAmmo7 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo7") 
              local playerWeaponAmmo8 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo8") 
              local playerWeaponAmmo9 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo9") 
              local playerWeaponAmmo10 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo10") 
              local playerWeaponAmmo11 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo11") 
              local playerWeaponAmmo12 = getAccountData (theCurrentAccount, "funmodev2-weaponAmmo12") 
               
              spawnPlayer ( thePlayer, playerX, playerY, playerZ + 2, 90.0, skin ,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) 
            else 
              spawnPlayer(source,1459.64014,-1643.40723, 438.94131,90.0,skin,0,0) 
              giveWeapon(source,46,1,true) 
              setCameraTarget (source, source) 
              setPlayerMoney(source,2500) 
        end 
         
    setCameraTarget (source, source) 
    setPlayerMoney(source,accountData) 
    playerSkin[source] = {skin,r,g,b} 
    setElementData(source,"Score",0) 
    setPlayerNametagShowing ( source, false) 
end 
addEvent( "onClientWantsToSpawn", true ) 
addEventHandler( "onClientWantsToSpawn", getRootElement(), SpawnPlayer ) 

and sorry but I'm not testing the codes that I'm suggesting. I do not currently meet in my pc :|

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...