
proracer
Members-
Posts
499 -
Joined
-
Last visited
Everything posted by proracer
-
You are again using functions: getPlayerAccount and isGuestAccount which only work for serverside. Btw, can you tell again what are trying to achieve?
-
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 )
-
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)
-
I use the same tool as Timic and yeah I like it alot.
-
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
-
Account data's doesn't work with clientside files, you should use setElementData / getElementData instead.
-
https://wiki.multitheftauto.com/wiki/TriggerServerEvent
-
I have tried your code and it works in my local server... Make sure you type: /setcash Example: /setcash proracer 100
-
Wow dude I like it alot, nice job!
-
Then you must edit line 2 I think.
-
I have one question too ... Can I use this function to represent next map with dx drawing?
-
You must type /setcash for it to work.
-
Because people first used C++ or any other similiar programming language but you can write it in Lua too if you want.
-
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 )
-
How can the data be lost if you can use it on userpanel's and aswell on scoreboard data's ...?
-
Yes, it will save when you even reconnect. There is also small alternative function if you wanna use: https://wiki.multitheftauto.com/wiki/SetAccountData
-
I have edited my last post, please try again.
-
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 )
-
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 )
-
setPlayerMoney doesn't work in Race mode ... You must create element data for cash by yourself.
-
If this bug occurs in your code you can easily transfer to normal tag without Lua syntax highlightning.
-
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 )
-
@Citizen: It represents ID of Death Reason: https://wiki.multitheftauto.com/wiki/Death_Reasons
-
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 )
-
You're trying to iterate "maps" table but where is it?