Jump to content

Save system. Help Me


iPanda

Recommended Posts

Posted

-

Hello everyone. It's my system for the preservation of my RPG fashion.

It does not work, help me make it work. :cry:

-- Here you can use tables, so that the script remains more clear ... 
local gamemode = "funmodev2"; 
  
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
    if isGuestAccount (getPlayerAccount (source)) then return; end; 
    -- here I thinks is better hold a data "funmodev2-datasaved" to check if 
    -- data is saved or not. 
    -- check if our data is saved. 
    if getAccountData (gamemode .. "-datasaved") then 
        -- extract the data. 
        -- you need to convert strings to numbers with tonumber. 
        -- be careful with that,cause getAccountData always return a string. 
        local playerMoney  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-money")) 
        local playerSkin   = tonumber (getAccountData (theCurrentAccount, gamemode .. "-skin")) 
        local playerHealth = tonumber (getAccountData (theCurrentAccount, gamemode .. "-health")) 
        local playerArmor  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-armor")) 
        local R = tonumber (getAccountData (theCurrentAccount, gamemode .. "-R")) 
        local G  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-G")) 
        local B  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-B")) 
        local playerX = tonumber (getAccountData (theCurrentAccount, gamemode .. "-x")) 
        local playerY = tonumber (getAccountData (theCurrentAccount, gamemode .. "-y")) 
        local playerZ = tonumber (getAccountData (theCurrentAccount, gamemode .. "-z")) 
        local playerInt = tonumber (getAccountData (theCurrentAccount, gamemode .. "-int")) 
        local playerDim = tonumber (getAccountData (theCurrentAccount, gamemode .. "-dim")) 
        local playerWanted = tonumber (getAccountData (theCurrentAccount, gamemode .. "-wantedlevel")) 
        local playerWeapon = {}; -- store all player weapons in a table. 
        local playerWeaponAmmo = {}; -- store weapon amnos in a table. 
        -- load all weapons & amno just with few lines. 
        for i=0,12,1 do 
            playerWeapon [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "-weaponID" .. tostring (i))) 
            playerWeaponAmmo [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "weaponAmno" .. tostring (i))) 
        end; 
  
        spawnPlayer (source, playerX, playerY, playerZ+1, 0, playerSkin, playerInt, playerDim) 
        setPlayerMoney  (source, playerMoney); 
        -- here just use 1 one timer. why use 3? 
        setTimer ( 
            function (thePlayer, health, armor, wantedLevel) 
                setElementHealth (thePlayer, health) 
                setPedArmor (thePlayer, armor) 
                setPlayerWantedLevel (thePlayer, wantedLevel) 
            end, 
            500, 1, source, playerHealth, playerArmor, playerWanted) 
        -- give weapons to player with just few lines with a loop. 
        for i=1,12,1 do 
            giveWeapon (source, playerWeapon [i], playerWeaponAmmo [i], false) 
        end 
        giveWeapon (source, playerWeapon [0], playerWeaponAmmo [0], true) 
        setCameraTarget (source, source) 
        fadeCamera (source, true, 2.0) 
        setPlayerNametagColor (source, R, G, B) 
    else 
        spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, nil) 
        setPlayerMoney ( source, 100) 
        setElementHealth ( source, 100) 
        setPedArmor ( source, 10) 
        giveWeapon ( source, 31, 200) 
    end 
end 
  
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) 
  
function onLogout () 
    -- instead of kick the player when trying to logout, just cancel the 
    -- event so that you can avoid him to logout without kick him. (I guess) 
    -- tell him that he cannot logout ... 
    outputChatBox ("You cannot logout!", source, 255, 50, 0) 
end 
  
addEventHandler ("onPlayerLogout", getRootElement(), onLogout) 
  
function onQuit (quitType, reason, responsibleElement) 
    if isGuestAccount (getPlayerAccount (source)) then return end 
    local account = getPlayerAccount (source) 
    if not account then return end 
    -- save the data. 
    local x,y,z = getElementPosition (source) 
    local r,g,b = getPlayerNametagColor (source) 
    setAccountData(account, gamemode .. "-money", tostring (getPlayerMoney (source))) 
    setAccountData(account, gamemode .. "-skin", tostring (getElementModel (source))) 
    setAccountData(account, gamemode .. "-health", tostring (getElementHealth (source))) 
    setAccountData(account, gamemode .. "-armor", tostring (getPedArmor (source))) 
    setAccountData(account, gamemode .. "-R", tostring (r)) 
    setAccountData(account, gamemode .. "-G", tostring (g)) 
    setAccountData(account, gamemode .. "-B", tostring (b)) 
    setAccountData(account, gamemode .. "-x", tostring (x)) 
    setAccountData(account, gamemode .. "-y", tostring (y)) 
    setAccountData(account, gamemode .. "-z", tostring (z)) 
    setAccountData(account, gamemode .. "-int", tostring (getElementInterior (source))) 
    setAccountData(account, gamemode .. "-dim", tostring (getElementDimension (source))) 
    setAccountData(account, gamemode .. "-wantedlevel", tostring (getPlayerWantedLevel (source))) 
    -- to store weapons & weapon amno, you can do it better with a loop. 
    for i=0,12,1 do 
        setAccountData(account, gamemode .. "-weaponID" .. tostring (i), tostring (getPedWeapon (source, i))) 
        setAccountData(account, gamemode .. "-weaponAmmo" .. tostring (i), tostring (getPedTotalAmmo (source, i))) 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) 
  if isGuestAccount (getPlayerAccount(source)) then return; end; 
    local theWeapon = getPedWeapon (source) 
    local weaponAmmo = getPedTotalAmmo (source) 
    fadeCamera (source, false) 
    -- here just use 3 timers instead of 4. 
    setTimer (spawnPlayer, 1000, 1, source, 2036.1735839844, -1413.0563964844, 16.9921875, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
    setTimer (setCameraTarget, 1250, 1, source, source) 
    setTimer ( 
        function (thePlayer) 
            fadeCamera (thePlayer, true) 
            giveWeapon (source, 31, 200, true) 
        end, 2000, 1, source, theWeapon, weaponAmmo) 
end 
addEventHandler ("onPlayerWasted", getRootElement(), onWasted) 
  
function spawnLastPlayer ( posX, posY, posZ, rotZ, theSkin, theInterior, theDimension, theTeam ) 
  spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, spawnTeam ) 
  givePlayerMoney ( source, 100 ) 
  setElementHealth ( source, 100 ) 
  setPedArmor ( source, 10 ) 
  giveWeapon ( source, 31, 200 ) 
  fadeCamera (source, true) 
  setCameraTarget (source, source) 
  removeEventHandler ("onPlayerSpawn", source, spawnLastPlayer); 
end 
  
addEventHandler ("onPlayerJoin", getRootElement (), 
    function () 
        addEventHandler ( "onPlayerSpawn", source, spawnLastPlayer); 
    end 
) 

-

Posted
Go to your server and write "/debugscript 3", then see if there's any error from this script.

"/debugscript 3" shows nothing! Conservation does not work, please help me ...

Posted

Are you sure that it doesn't show anything? because lately lot of people has been telling me that nothing shows up, but then I go to my test server and it spams the debug with errors from their scripts.

Posted
Are you sure that it doesn't show anything? because lately lot of people has been telling me that nothing shows up, but then I go to my test server and it spams the debug with errors from their scripts.

bad argument getAccountData

Posted
if getAccountData (gamemode .. "-datasaved") then 

On that line, for sure. What is that line for?

I do not know. Here's a screenshot:

mbTNJjjY1n0.jpg

Posted
-- Here you can use tables, so that the script remains more clear ... 
local gamemode = "funmodev2"; 
  
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
    if isGuestAccount (getPlayerAccount (source)) then return; end; 
    -- here I thinks is better hold a data "funmodev2-datasaved" to check if 
    -- data is saved or not. 
    -- check if our data is saved. 
    if getAccountData ( theCurrentAccount, gamemode .. "-datasaved") then 
        -- extract the data. 
        -- you need to convert strings to numbers with tonumber. 
        -- be careful with that,cause getAccountData always return a string. 
        local playerMoney  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-money")) 
        local playerSkin   = tonumber (getAccountData (theCurrentAccount, gamemode .. "-skin")) 
        local playerHealth = tonumber (getAccountData (theCurrentAccount, gamemode .. "-health")) 
        local playerArmor  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-armor")) 
        local R = tonumber (getAccountData (theCurrentAccount, gamemode .. "-R")) 
        local G  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-G")) 
        local B  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-B")) 
        local playerX = tonumber (getAccountData (theCurrentAccount, gamemode .. "-x")) 
        local playerY = tonumber (getAccountData (theCurrentAccount, gamemode .. "-y")) 
        local playerZ = tonumber (getAccountData (theCurrentAccount, gamemode .. "-z")) 
        local playerInt = tonumber (getAccountData (theCurrentAccount, gamemode .. "-int")) 
        local playerDim = tonumber (getAccountData (theCurrentAccount, gamemode .. "-dim")) 
        local playerWanted = tonumber (getAccountData (theCurrentAccount, gamemode .. "-wantedlevel")) 
        local playerWeapon = {}; -- store all player weapons in a table. 
        local playerWeaponAmmo = {}; -- store weapon amnos in a table. 
        -- load all weapons & amno just with few lines. 
        for i=0,12,1 do 
            playerWeapon [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "-weaponID" .. tostring (i))) 
            playerWeaponAmmo [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "weaponAmno" .. tostring (i))) 
        end; 
  
        spawnPlayer (source, playerX, playerY, playerZ+1, 0, playerSkin, playerInt, playerDim) 
        setPlayerMoney  (source, playerMoney); 
        -- here just use 1 one timer. why use 3? 
        setTimer ( 
            function (thePlayer, health, armor, wantedLevel) 
                setElementHealth (thePlayer, health) 
                setPedArmor (thePlayer, armor) 
                setPlayerWantedLevel (thePlayer, wantedLevel) 
            end, 
            500, 1, source, playerHealth, playerArmor, playerWanted) 
        -- give weapons to player with just few lines with a loop. 
        for i=1,12,1 do 
            giveWeapon (source, playerWeapon [i], playerWeaponAmmo [i], false) 
        end 
        giveWeapon (source, playerWeapon [0], playerWeaponAmmo [0], true) 
        setCameraTarget (source, source) 
        fadeCamera (source, true, 2.0) 
        setPlayerNametagColor (source, R, G, B) 
    else 
        spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, nil) 
        setPlayerMoney ( source, 100) 
        setElementHealth ( source, 100) 
        setPedArmor ( source, 10) 
        giveWeapon ( source, 31, 200) 
    end 
end 
  
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) 
  
function onLogout () 
    -- instead of kick the player when trying to logout, just cancel the 
    -- event so that you can avoid him to logout without kick him. (I guess) 
    -- tell him that he cannot logout ... 
    outputChatBox ("You cannot logout!", source, 255, 50, 0) 
end 
  
addEventHandler ("onPlayerLogout", getRootElement(), onLogout) 
  
function onQuit (quitType, reason, responsibleElement) 
    if isGuestAccount (getPlayerAccount (source)) then return end 
    local account = getPlayerAccount (source) 
    if not account then return end 
    -- save the data. 
    local x,y,z = getElementPosition (source) 
    local r,g,b = getPlayerNametagColor (source) 
    setAccountData(account, gamemode .. "-money", tostring (getPlayerMoney (source))) 
    setAccountData(account, gamemode .. "-skin", tostring (getElementModel (source))) 
    setAccountData(account, gamemode .. "-health", tostring (getElementHealth (source))) 
    setAccountData(account, gamemode .. "-armor", tostring (getPedArmor (source))) 
    setAccountData(account, gamemode .. "-R", tostring (r)) 
    setAccountData(account, gamemode .. "-G", tostring (g)) 
    setAccountData(account, gamemode .. "-B", tostring (b)) 
    setAccountData(account, gamemode .. "-x", tostring (x)) 
    setAccountData(account, gamemode .. "-y", tostring (y)) 
    setAccountData(account, gamemode .. "-z", tostring (z)) 
    setAccountData(account, gamemode .. "-int", tostring (getElementInterior (source))) 
    setAccountData(account, gamemode .. "-dim", tostring (getElementDimension (source))) 
    setAccountData(account, gamemode .. "-wantedlevel", tostring (getPlayerWantedLevel (source))) 
    setAccountData(account, gamemode .. "-datasaved", true) 
    -- to store weapons & weapon amno, you can do it better with a loop. 
    for i=0,12,1 do 
        setAccountData(account, gamemode .. "-weaponID" .. tostring (i), tostring (getPedWeapon (source, i))) 
        setAccountData(account, gamemode .. "-weaponAmmo" .. tostring (i), tostring (getPedTotalAmmo (source, i))) 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) 
  if isGuestAccount (getPlayerAccount(source)) then return; end; 
    local theWeapon = getPedWeapon (source) 
    local weaponAmmo = getPedTotalAmmo (source) 
    fadeCamera (source, false) 
    -- here just use 3 timers instead of 4. 
    setTimer (spawnPlayer, 1000, 1, source, 2036.1735839844, -1413.0563964844, 16.9921875, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
    setTimer (setCameraTarget, 1250, 1, source, source) 
    setTimer ( 
        function (thePlayer) 
            fadeCamera (thePlayer, true) 
            giveWeapon (source, 31, 200, true) 
        end, 2000, 1, source, theWeapon, weaponAmmo) 
end 
addEventHandler ("onPlayerWasted", getRootElement(), onWasted) 
  
function spawnLastPlayer ( posX, posY, posZ, rotZ, theSkin, theInterior, theDimension, theTeam ) 
  spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, spawnTeam ) 
  givePlayerMoney ( source, 100 ) 
  setElementHealth ( source, 100 ) 
  setPedArmor ( source, 10 ) 
  giveWeapon ( source, 31, 200 ) 
  fadeCamera (source, true) 
  setCameraTarget (source, source) 
  removeEventHandler ("onPlayerSpawn", source, spawnLastPlayer); 
end 
  
addEventHandler ("onPlayerJoin", getRootElement (), 
    function () 
        addEventHandler ( "onPlayerSpawn", source, spawnLastPlayer); 
    end 
) 

Posted
-- Here you can use tables, so that the script remains more clear ... 
local gamemode = "funmodev2"; 
  
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
    if isGuestAccount (getPlayerAccount (source)) then return; end; 
    -- here I thinks is better hold a data "funmodev2-datasaved" to check if 
    -- data is saved or not. 
    -- check if our data is saved. 
    if getAccountData ( theCurrentAccount, gamemode .. "-datasaved") then 
        -- extract the data. 
        -- you need to convert strings to numbers with tonumber. 
        -- be careful with that,cause getAccountData always return a string. 
        local playerMoney  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-money")) 
        local playerSkin   = tonumber (getAccountData (theCurrentAccount, gamemode .. "-skin")) 
        local playerHealth = tonumber (getAccountData (theCurrentAccount, gamemode .. "-health")) 
        local playerArmor  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-armor")) 
        local R = tonumber (getAccountData (theCurrentAccount, gamemode .. "-R")) 
        local G  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-G")) 
        local B  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-B")) 
        local playerX = tonumber (getAccountData (theCurrentAccount, gamemode .. "-x")) 
        local playerY = tonumber (getAccountData (theCurrentAccount, gamemode .. "-y")) 
        local playerZ = tonumber (getAccountData (theCurrentAccount, gamemode .. "-z")) 
        local playerInt = tonumber (getAccountData (theCurrentAccount, gamemode .. "-int")) 
        local playerDim = tonumber (getAccountData (theCurrentAccount, gamemode .. "-dim")) 
        local playerWanted = tonumber (getAccountData (theCurrentAccount, gamemode .. "-wantedlevel")) 
        local playerWeapon = {}; -- store all player weapons in a table. 
        local playerWeaponAmmo = {}; -- store weapon amnos in a table. 
        -- load all weapons & amno just with few lines. 
        for i=0,12,1 do 
            playerWeapon [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "-weaponID" .. tostring (i))) 
            playerWeaponAmmo [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "weaponAmno" .. tostring (i))) 
        end; 
  
        spawnPlayer (source, playerX, playerY, playerZ+1, 0, playerSkin, playerInt, playerDim) 
        setPlayerMoney  (source, playerMoney); 
        -- here just use 1 one timer. why use 3? 
        setTimer ( 
            function (thePlayer, health, armor, wantedLevel) 
                setElementHealth (thePlayer, health) 
                setPedArmor (thePlayer, armor) 
                setPlayerWantedLevel (thePlayer, wantedLevel) 
            end, 
            500, 1, source, playerHealth, playerArmor, playerWanted) 
        -- give weapons to player with just few lines with a loop. 
        for i=1,12,1 do 
            giveWeapon (source, playerWeapon [i], playerWeaponAmmo [i], false) 
        end 
        giveWeapon (source, playerWeapon [0], playerWeaponAmmo [0], true) 
        setCameraTarget (source, source) 
        fadeCamera (source, true, 2.0) 
        setPlayerNametagColor (source, R, G, B) 
    else 
        spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, nil) 
        setPlayerMoney ( source, 100) 
        setElementHealth ( source, 100) 
        setPedArmor ( source, 10) 
        giveWeapon ( source, 31, 200) 
    end 
end 
  
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) 
  
function onLogout () 
    -- instead of kick the player when trying to logout, just cancel the 
    -- event so that you can avoid him to logout without kick him. (I guess) 
    -- tell him that he cannot logout ... 
    outputChatBox ("You cannot logout!", source, 255, 50, 0) 
end 
  
addEventHandler ("onPlayerLogout", getRootElement(), onLogout) 
  
function onQuit (quitType, reason, responsibleElement) 
    if isGuestAccount (getPlayerAccount (source)) then return end 
    local account = getPlayerAccount (source) 
    if not account then return end 
    -- save the data. 
    local x,y,z = getElementPosition (source) 
    local r,g,b = getPlayerNametagColor (source) 
    setAccountData(account, gamemode .. "-money", tostring (getPlayerMoney (source))) 
    setAccountData(account, gamemode .. "-skin", tostring (getElementModel (source))) 
    setAccountData(account, gamemode .. "-health", tostring (getElementHealth (source))) 
    setAccountData(account, gamemode .. "-armor", tostring (getPedArmor (source))) 
    setAccountData(account, gamemode .. "-R", tostring (r)) 
    setAccountData(account, gamemode .. "-G", tostring (g)) 
    setAccountData(account, gamemode .. "-B", tostring (b)) 
    setAccountData(account, gamemode .. "-x", tostring (x)) 
    setAccountData(account, gamemode .. "-y", tostring (y)) 
    setAccountData(account, gamemode .. "-z", tostring (z)) 
    setAccountData(account, gamemode .. "-int", tostring (getElementInterior (source))) 
    setAccountData(account, gamemode .. "-dim", tostring (getElementDimension (source))) 
    setAccountData(account, gamemode .. "-wantedlevel", tostring (getPlayerWantedLevel (source))) 
    setAccountData(account, gamemode .. "-datasaved", true) 
    -- to store weapons & weapon amno, you can do it better with a loop. 
    for i=0,12,1 do 
        setAccountData(account, gamemode .. "-weaponID" .. tostring (i), tostring (getPedWeapon (source, i))) 
        setAccountData(account, gamemode .. "-weaponAmmo" .. tostring (i), tostring (getPedTotalAmmo (source, i))) 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) 
  if isGuestAccount (getPlayerAccount(source)) then return; end; 
    local theWeapon = getPedWeapon (source) 
    local weaponAmmo = getPedTotalAmmo (source) 
    fadeCamera (source, false) 
    -- here just use 3 timers instead of 4. 
    setTimer (spawnPlayer, 1000, 1, source, 2036.1735839844, -1413.0563964844, 16.9921875, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
    setTimer (setCameraTarget, 1250, 1, source, source) 
    setTimer ( 
        function (thePlayer) 
            fadeCamera (thePlayer, true) 
            giveWeapon (source, 31, 200, true) 
        end, 2000, 1, source, theWeapon, weaponAmmo) 
end 
addEventHandler ("onPlayerWasted", getRootElement(), onWasted) 
  
function spawnLastPlayer ( posX, posY, posZ, rotZ, theSkin, theInterior, theDimension, theTeam ) 
  spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, spawnTeam ) 
  givePlayerMoney ( source, 100 ) 
  setElementHealth ( source, 100 ) 
  setPedArmor ( source, 10 ) 
  giveWeapon ( source, 31, 200 ) 
  fadeCamera (source, true) 
  setCameraTarget (source, source) 
  removeEventHandler ("onPlayerSpawn", source, spawnLastPlayer); 
end 
  
addEventHandler ("onPlayerJoin", getRootElement (), 
    function () 
        addEventHandler ( "onPlayerSpawn", source, spawnLastPlayer); 
    end 
) 

No, it does not work. When I login, I am re-SPAWN

WARNING!!!

This error no longer provides:

[22:17:20] WARNING: alpha\spawn.lua:10: Bad argument @ "getAccountData"

Now there was only this error:

[22:17:20] ERROR: alpha\spawn.lua:134: C stack overflow

Posted
Post the script that caused the error you last posted.

I do not have a clue about what you write! I simply do not understand!

Posted
You're start to confusing Castillo, post the full codes for spawner.
-- Here you can use tables, so that the script remains more clear ... 
local gamemode = "funmodev2"; 
  
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin) 
    if isGuestAccount (getPlayerAccount (source)) then return; end; 
    -- here I thinks is better hold a data "funmodev2-datasaved" to check if 
    -- data is saved or not. 
    -- check if our data is saved. 
    if getAccountData ( theCurrentAccount, gamemode .. "-datasaved") then 
        -- extract the data. 
        -- you need to convert strings to numbers with tonumber. 
        -- be careful with that,cause getAccountData always return a string. 
        local playerMoney  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-money")) 
        local playerSkin   = tonumber (getAccountData (theCurrentAccount, gamemode .. "-skin")) 
        local playerHealth = tonumber (getAccountData (theCurrentAccount, gamemode .. "-health")) 
        local playerArmor  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-armor")) 
        local R = tonumber (getAccountData (theCurrentAccount, gamemode .. "-R")) 
        local G  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-G")) 
        local B  = tonumber (getAccountData (theCurrentAccount, gamemode .. "-B")) 
        local playerX = tonumber (getAccountData (theCurrentAccount, gamemode .. "-x")) 
        local playerY = tonumber (getAccountData (theCurrentAccount, gamemode .. "-y")) 
        local playerZ = tonumber (getAccountData (theCurrentAccount, gamemode .. "-z")) 
        local playerInt = tonumber (getAccountData (theCurrentAccount, gamemode .. "-int")) 
        local playerDim = tonumber (getAccountData (theCurrentAccount, gamemode .. "-dim")) 
        local playerWanted = tonumber (getAccountData (theCurrentAccount, gamemode .. "-wantedlevel")) 
        local playerWeapon = {}; -- store all player weapons in a table. 
        local playerWeaponAmmo = {}; -- store weapon amnos in a table. 
        -- load all weapons & amno just with few lines. 
        for i=0,12,1 do 
            playerWeapon [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "-weaponID" .. tostring (i))) 
            playerWeaponAmmo [i] = tonumber (getAccountData (theCurrentAccount, gamemode .. "weaponAmno" .. tostring (i))) 
        end; 
  
        spawnPlayer (source, playerX, playerY, playerZ+1, 0, playerSkin, playerInt, playerDim) 
        setPlayerMoney  (source, playerMoney); 
        -- here just use 1 one timer. why use 3? 
        setTimer ( 
            function (thePlayer, health, armor, wantedLevel) 
                setElementHealth (thePlayer, health) 
                setPedArmor (thePlayer, armor) 
                setPlayerWantedLevel (thePlayer, wantedLevel) 
            end, 
            500, 1, source, playerHealth, playerArmor, playerWanted) 
        -- give weapons to player with just few lines with a loop. 
        for i=1,12,1 do 
            giveWeapon (source, playerWeapon [i], playerWeaponAmmo [i], false) 
        end 
        giveWeapon (source, playerWeapon [0], playerWeaponAmmo [0], true) 
        setCameraTarget (source, source) 
        fadeCamera (source, true, 2.0) 
        setPlayerNametagColor (source, R, G, B) 
    else 
        spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, nil) 
        setPlayerMoney ( source, 100) 
        setElementHealth ( source, 100) 
        setPedArmor ( source, 10) 
        giveWeapon ( source, 31, 200) 
    end 
end 
  
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin) 
  
function onLogout () 
    -- instead of kick the player when trying to logout, just cancel the 
    -- event so that you can avoid him to logout without kick him. (I guess) 
    -- tell him that he cannot logout ... 
    outputChatBox ("You cannot logout!", source, 255, 50, 0) 
end 
  
addEventHandler ("onPlayerLogout", getRootElement(), onLogout) 
  
function onQuit (quitType, reason, responsibleElement) 
    if isGuestAccount (getPlayerAccount (source)) then return end 
    local account = getPlayerAccount (source) 
    if not account then return end 
    -- save the data. 
    local x,y,z = getElementPosition (source) 
    local r,g,b = getPlayerNametagColor (source) 
    setAccountData(account, gamemode .. "-money", tostring (getPlayerMoney (source))) 
    setAccountData(account, gamemode .. "-skin", tostring (getElementModel (source))) 
    setAccountData(account, gamemode .. "-health", tostring (getElementHealth (source))) 
    setAccountData(account, gamemode .. "-armor", tostring (getPedArmor (source))) 
    setAccountData(account, gamemode .. "-R", tostring (r)) 
    setAccountData(account, gamemode .. "-G", tostring (g)) 
    setAccountData(account, gamemode .. "-B", tostring (b)) 
    setAccountData(account, gamemode .. "-x", tostring (x)) 
    setAccountData(account, gamemode .. "-y", tostring (y)) 
    setAccountData(account, gamemode .. "-z", tostring (z)) 
    setAccountData(account, gamemode .. "-int", tostring (getElementInterior (source))) 
    setAccountData(account, gamemode .. "-dim", tostring (getElementDimension (source))) 
    setAccountData(account, gamemode .. "-wantedlevel", tostring (getPlayerWantedLevel (source))) 
    setAccountData(account, gamemode .. "-datasaved", true) 
    -- to store weapons & weapon amno, you can do it better with a loop. 
    for i=0,12,1 do 
        setAccountData(account, gamemode .. "-weaponID" .. tostring (i), tostring (getPedWeapon (source, i))) 
        setAccountData(account, gamemode .. "-weaponAmmo" .. tostring (i), tostring (getPedTotalAmmo (source, i))) 
    end 
end 
addEventHandler ("onPlayerQuit", getRootElement(), onQuit) 
  
function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) 
  if isGuestAccount (getPlayerAccount(source)) then return; end; 
    local theWeapon = getPedWeapon (source) 
    local weaponAmmo = getPedTotalAmmo (source) 
    fadeCamera (source, false) 
    -- here just use 3 timers instead of 4. 
    setTimer (spawnPlayer, 1000, 1, source, 2036.1735839844, -1413.0563964844, 16.9921875, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) 
    setTimer (setCameraTarget, 1250, 1, source, source) 
    setTimer ( 
        function (thePlayer) 
            fadeCamera (thePlayer, true) 
            giveWeapon (source, 31, 200, true) 
        end, 2000, 1, source, theWeapon, weaponAmmo) 
end 
addEventHandler ("onPlayerWasted", getRootElement(), onWasted) 
  
function spawnLastPlayer ( posX, posY, posZ, rotZ, theSkin, theInterior, theDimension, theTeam ) 
  spawnPlayer ( source, 2005.25, 1544.80, 13.5907, 0, 286, 0, 0, nil ) 
  givePlayerMoney ( source, 100 ) 
  setElementHealth ( source, 100 ) 
  setPedArmor ( source, 10 ) 
  giveWeapon ( source, 31, 200 ) 
  fadeCamera (source, true) 
  setCameraTarget (source, source) 
  removeEventHandler ("onPlayerSpawn", source, spawnLastPlayer); 
end 
  
addEventHandler ("onPlayerJoin", getRootElement (), 
    function () 
        addEventHandler ( "onPlayerSpawn", source, spawnLastPlayer); 
    end 
) 

This is full code! Does not work, I spent a month on it and I do not know what to do! Help me!

Posted
But this is what you posted:
[22:17:20] ERROR: alpha\spawn.lua:134: C stack overflow

And there's no line 134. Only 132.

yes, only 132 lines. Why 134?

At the moment, gives an error on line 118

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