Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. No, that doesn't make any sense. addEventHandler ( "onPlayerJoin", root, function ( ) setPedWalkingStyle ( source, 121 ) end )
  2. Well, 'source' must be a player, you can set it when player joins, use onPlayerJoin.
  3. You must use the function: createTeam
  4. getElementModel returns a number, not a table.
  5. Nice one and unique, good luck with it!
  6. You can send the arguments to the second function.
  7. It's part of the freeroam resource, you can remove it from the script.
  8. Post the script that caused the error you last posted.
  9. The script on this topic doesn't have 134 lines.
  10. There isn't a line 134.
  11. Castillo

    Money

    If you set/give/take money client side it won't sync with the server.
  12. -- 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 )
  13. if getAccountData (gamemode .. "-datasaved") then On that line, for sure. What is that line for?
  14. Well, that's obviously... is what your script does.
  15. Add an outputChatBox to see what "lvl1" returns.
  16. What has that to do with what I said?
  17. setAccountData(getPlayerAccount(source), "lvl1", lvl) Your variable is "lvl1" not "lvl".
×
×
  • Create New...