maarten123 Posted July 7, 2010 Share Posted July 7, 2010 Hi, I want a script for you if you win you get money. but now is my question how can I get the rank. I will that 1st guy get $100 money and teh 2nd $30 for instance can anyone help me ? greetings maarten123 sorry for my bad english i am dutch Link to comment
50p Posted July 7, 2010 Share Posted July 7, 2010 You need some MTA scripting knowledge not just Lua itself. This is your highest priority. Then you can make it yourself with a 10 lines script: https://wiki.multitheftauto.com/wiki/Resource:Race What do you need money for on a race server? Where do you spend it? Link to comment
maarten123 Posted July 7, 2010 Author Share Posted July 7, 2010 You need some MTA scripting knowledge not just Lua itself. This is your highest priority. Then you can make it yourself with a 10 lines script: https://wiki.multitheftauto.com/wiki/Resource:RaceWhat do you need money for on a race server? Where do you spend it? For example, the nitro or repair. I can also bit MTA LUA, but I may know not what event I should use. iik saw on the forum have a small script but I do not know if that works. function check() local alive = getAlivePlayers() if (#alive == 1) then local player = alive[1] givePlayerMoney(player,1200) outputChatBox(getPlayerName(player).." has earned $1200 for being the last player alive",getRootElement(),0,255,0) else outputChatBox("helaas",getRootElement(),0,255,0) end end addEventHandler("onPlayerWasted",getRootElement(),check) Link to comment
50p Posted July 7, 2010 Share Posted July 7, 2010 Well, I gave you a link which you seem to ignore like most people... Link to comment
maarten123 Posted July 7, 2010 Author Share Posted July 7, 2010 Well, I gave you a link which you seem to ignore like most people... yes, sorry but i dont now if that events will work for DD or DM Link to comment
50p Posted July 7, 2010 Share Posted July 7, 2010 Why don't you try? Besides, you never said what kind of race. Link to comment
maarten123 Posted July 11, 2010 Author Share Posted July 11, 2010 Why don't you try? Besides, you never said what kind of race. ok i have make a script but there is a bug look: function checkWinAndIfWinGiveWinCash (totalAmmo,killer,killerWeapon,bodypart,stealth) local rank = getAliveCount() if (rank == 1) then local allAlivePlayers = getAlivePlayers() local player = allAlivePlayers[1] local playerCount = getPlayerCount() local pointsToWin = playerCount *13 local cashToWin = playerCount *53 savePlayerData (player,"points",loadPlayerData(player,"points") + pointsToWin) savePlayerData (player,"cash",loadPlayerData(player,"cash") +cashToWin) outputChatBox (getPlayerName(player) .." #FF0000is first! He wins " .. tostring(pointsToWin) .." points and " .. tostring(cashToWin) .."$!",getRootElement(),255,0,0,true) end if(rank == 2) then outputChatBox (getPlayerName(player) .." #FF0000is 2nd!",getRootElement(),255,0,0,true) end end addEventHandler ("onPlayerWasted",getRootElement(),checkWinAndIfWinGiveWinCash) addEventHandler ("onPlayerQuit",getRootElement(),checkWinAndIfWinGiveWinCash) i don't see if i seccond the message, and elseif don't work Maarten123 Link to comment
MaddDogg Posted July 11, 2010 Share Posted July 11, 2010 Output the rank and see, if it is 2, when you're second ranked. If not, then most likely the getAliveCount function has a mistake in it. Also, you should make use of elseif at this point: if(rank == 2) then Link to comment
maarten123 Posted July 11, 2010 Author Share Posted July 11, 2010 Output the rank and see, if it is 2, when you're second ranked.If not, then most likely the getAliveCount function has a mistake in it. Also, you should make use of elseif at this point: if(rank == 2) then function checkWinAndIfWinGiveWinCash (totalAmmo,killer,killerWeapon,bodypart,stealth) local rank = getAliveCount() if (rank == 1) then local allAlivePlayers = getAlivePlayers() local player = allAlivePlayers[1] local playerCount = getPlayerCount() local pointsToWin = playerCount *13 local cashToWin = playerCount *53 savePlayerData (player,"points",loadPlayerData(player,"points") + pointsToWin) savePlayerData (player,"cash",loadPlayerData(player,"cash") +cashToWin) outputChatBox (getPlayerName(player) .." #FF0000is first! He wins " .. tostring(pointsToWin) .." points and " .. tostring(cashToWin) .."$!",getRootElement(),255,0,0,true) end if(rank == 2) then local allAlivePlayers = getAlivePlayers() local player = allAlivePlayers[2] local playerCount = getPlayerCount() local pointsToWin = playerCount *13 local cashToWin = playerCount *53 outputChatBox (getPlayerName(player) .." #FF0000is 2nd!",getRootElement(),255,0,0,true) end end like this? but now is it bugged i wnat if all players dead then he say your 2dn or first Link to comment
maarten123 Posted July 11, 2010 Author Share Posted July 11, 2010 function check() local alive = getAlivePlayers() if (#alive == 1) then local player = alive[1] givePlayerMoney(player,1200) outputChatBox(getPlayerName(player).." is first!",getRootElement(),0,255,0) end if(#alive == 2) then local player2 = alive[2] outputChatBox(getPlayerName(player2).." is second!",getRootElement(),0,255,0) end end addEventHandler("onPlayerWasted",getRootElement(),check) this is a simpel version of that nut that is too bugged Link to comment
maarten123 Posted July 11, 2010 Author Share Posted July 11, 2010 function check() local alive = getAlivePlayers() if (#alive == 1) then local player = alive[1] givePlayerMoney(player,1200) outputChatBox(getPlayerName(player).." is first!",getRootElement(),0,255,0) end if(#alive == 2) then local player2 = alive[2] outputChatBox(getPlayerName(player2).." is second!",getRootElement(),0,255,0) end end addEventHandler("onPlayerWasted",getRootElement(),check) this is a simpel version of that nut that is too bugged i see the problem if you winning there are no 2 alive humans/cars so now i need the dead players and then i get the rank of him Link to comment
maarten123 Posted July 12, 2010 Author Share Posted July 12, 2010 Can anyone help me? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now