Jump to content

proracer

Members
  • Posts

    499
  • Joined

  • Last visited

Everything posted by proracer

  1. You are again using functions: getPlayerAccount and isGuestAccount which only work for serverside. Btw, can you tell again what are trying to achieve?
  2. function setAdmin ( sourcePlayer,cmd,who,level) if ( not who and not level ) then outputChatBox("*Use /makeadmin [Name] [level]", sourcePlayer, 180, 0, 0 ) return end local gived = getPlayerFromName ( who ) if not gived then outputChatBox("The player "..who.." is not connected", sourcePlayer, 180, 0, 0 ) return end account = getPlayerAccount(gived) if not isGuestAccount ( account ) then local success = setAccountData ( account, "data.adminlevel", tonumber(level)) if success then outputChatBox ( "Your admin level has been setted to " .. level .. ".", gived ) outputChatBox ( "You've setted his admin level to " .. level .. ".", sourcePlayer ) else outputChatBox("ERROR: His adminlevel his not setted", sourcePlayer, 180, 0, 0 ) end end end addCommandHandler ( "makeadmin", setAdmin )
  3. I didn't tested it yet but I saw small syntax error, look: local success = setAccountData ( account, "data.adminlevel", tonumber(playerAdmin) ,tonumber(amount)) You are using " , " instead of " + " and that will aply as a next argument so try this: local success = setAccountData ( account, "data.adminlevel", tonumber(playerAdmin)+tonumber(amount)) (line 9)
  4. I use the same tool as Timic and yeah I like it alot.
  5. It should work now .. tested, by the way I don't get "admin level" .. did you mean rank level or? function onWasted (ammo, killer) local account = getPlayerAccount(source) local getPlayerDeaths = getAccountData(account, "data.deaths" ) local getPlayerAdmin = getAccountData(account, "data.adminlevel" ) if getPlayerDeaths and getPlayerAdmin then local getPlayerCash = getAccountData(account, "data.cash" ) setTimer( spawnPlayer, 2000, 1, source, 1187.19,-1324.01,13.55 ) outputChatBox ( "You've paid 100$ for medical bill.", source ) setAccountData ( account, "data.cash", tonumber(getPlayerCash) - 100 ) setAccountData ( account, "data.deaths", tonumber(getPlayerDeaths) + 1 ) setAccountData ( account, "data.adminlevel", tonumber(getPlayerAdmin) + 1 ) outputChatBox ( "You are now admin level: " .. getPlayerAdmin, source ) else setAccountData ( account, "data.deaths", 1 ) setAccountData ( account, "data.adminlevel", 1 ) end addEventHandler ( "onPlayerWasted", root, onWasted ) end
  6. Account data's doesn't work with clientside files, you should use setElementData / getElementData instead.
  7. https://wiki.multitheftauto.com/wiki/TriggerServerEvent
  8. I have tried your code and it works in my local server... Make sure you type: /setcash Example: /setcash proracer 100
  9. Wow dude I like it alot, nice job!
  10. Then you must edit line 2 I think.
  11. I have one question too ... Can I use this function to represent next map with dx drawing?
  12. You must type /setcash for it to work.
  13. proracer

    Alpha Set :D

    Because people first used C++ or any other similiar programming language but you can write it in Lua too if you want.
  14. This should work, I tested it.. function onLoginSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) if getAccountData ( account, "data.cash" ) then givePlayerMoney(source, tonumber(getAccountData(account,"data.cash"))) outputChatBox ( "You're cash is transfered back!", source ) else setAccountData( account, "data.cash", 0 ) outputChatBox ( "You're new and your cash will now be saved." ) end end end function onWastedSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then local getPlayerCash = getAccountData ( account, "data.cash" ) setAccountData ( account, "data.cash", tonumber(getPlayerCash) + 100 ) outputChatBox ( "You got 100$ for your death.", source ) end end function onQuitSaveCash() if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) end end addEventHandler ( "onPlayerQuit", root, onQuitSaveCash ) function onLogoutSaveCash() if not isGuestAccount ( getPlayerAccount ( source ) ) then account = getPlayerAccount(source) setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) setPlayerMoney(source,0) end end addEventHandler ( "onPlayerLogout", root, onLogoutSaveCash ) addEventHandler ( "onPlayerLogin", root, onLoginSetCash ) addEventHandler ( "onPlayerWasted", root, onWastedSetCash ) function myCash ( thePlayer ) if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then account = getPlayerAccount(thePlayer) local cash = getAccountData ( account, "data.cash" ) outputChatBox ( "Your cash is: " .. tostring ( cash ) .. " $ ", thePlayer ) end end addCommandHandler ( "cash", myCash )
  15. How can the data be lost if you can use it on userpanel's and aswell on scoreboard data's ...?
  16. Yes, it will save when you even reconnect. There is also small alternative function if you wanna use: https://wiki.multitheftauto.com/wiki/SetAccountData
  17. I have edited my last post, please try again.
  18. Ok you can try this but I'm not sure if it will work... function onLoginSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then if getElementData ( source, "data.cash" ) then outputChatBox ( "You're cash is transfered back!", source ) else setElementData ( source, "data.cash", 0 ) outputChatBox ( "You're new and your cash will now be saved." ) end end end function onWastedSetCash ( ) if not isGuestAccount ( getPlayerAccount ( source ) ) then local getPlayerCash = getElementData ( source, "data.cash" ) setElementData ( source, "data.cash", getPlayerCash + 100 ) outputChatBox ( "You got 100$ for your death.", source ) end end addEventHandler ( "onPlayerLogin", root, onLoginSetCash ) addEventHandler ( "onPlayerWasted", root, onWastedSetCash )
  19. addCommandHandler("controlufo", function (thePlayer) if allowAll == false or allowAll == nil then if isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin" ) ) then triggerClientEvent("ufo:showmainGUI", thePlayer) elseif hasObjectPermissionTo ( thePlayer, "resource.afs-ufo.controlufo", false ) then triggerClientEvent("ufo:showmainGUI", thePlayer) else outputChatBox("#ff0000*UFO: #ffff00The UFO cannot be controlled by you at this time.", thePlayer, 255,255,255,true) end else triggerClientEvent("ufo:showmainGUI", thePlayer) end end )
  20. setPlayerMoney doesn't work in Race mode ... You must create element data for cash by yourself.
  21. If this bug occurs in your code you can easily transfer to normal tag without Lua syntax highlightning.
  22. Try this: -- It's serverside function mapsList() local resourceTable = getResources() triggerClientEvent ( "clearGridList", getRootElement() ) for resourceKey, resourceValue in ipairs(resourceTable) do local name = getResourceName(resourceValue) local type1 = getResourceInfo ( resourceValue, "type" ) local gamemode1 = getResourceInfo ( resourceValue, "gamemodes" ) if type1 == "map" and gamemode1 == "race" then triggerClientEvent ( "sendMaps", getRootElement(), name) else cancelEvent() end end end addCommandHandler( "sendMaps", mapsList, false, false )
  23. @Citizen: It represents ID of Death Reason: https://wiki.multitheftauto.com/wiki/Death_Reasons
  24. When a player logins it can't retrieve the account data because it is only set when he quits from server so you should try this: function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getPlayerMoney ( source ) setAccountData ( playeraccount, "savemoney.money", playermoney ) end end function onPlayerLogin ( ) -- when a player joins, retrieve his money amount from his account data and set it local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "savemoney.money" ) -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) else setPlayerMoney ( source, 0 ) -- if it cant retrieve data set it to 0 end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )
  25. You're trying to iterate "maps" table but where is it?
×
×
  • Create New...