Jump to content

[REL] Coin System


Enargy,

Recommended Posts

< Coin System >

Hey guys, I bring a coin system to avoid both use money game and use something different can have for a roleplay or specific server.

* features:

this system gives also be able to use in different incidents since it has functions that can be exported from himself.

- SERVER (syntax):

· setPlayerCoin (player theplayer, int amount) - set a specific value. 
· givePlayerCoin (player theplayer, int amount) - establishes a summed with the previous value. 
· takePlayerCoin (player theplayer, int amount) - the specific value is taken. 
· getPlayerCoin (player theplayer) - gets the values that has a player. 

- CLIENT-SIDE (syntax):

· getPlayerCoin (player theplayer) 

Examples:

function mycs(thePlayer, command) 
   local mycoins = exports.coinsystem:getPlayerCoin(thePlayer) 
   if ( mycoins >= 10000 ) then 
   outputChatBox("you have more than 10000 coins.", thePlayer, 0, 255, 0, false) 
   else 
   outputChatBox("you have less than 10000 coins.", thePlayer, 255, 0, 0, false)    
   end 
end 
addCommandHandler("coins", mycs) 

addEventHandler("onPlayerJoin", root, function() 
exports.coinsystem:setPlayerCoin(source, 1000) 
end) 

function buyWeapon(thePlayer, command) 
   local prize = 20000 
   local mycoins = exports.coinsystem:getPlayerCoin(thePlayer) 
   if ( mycoins >= tonumber(prize) ) then 
   giveWeapon(thePlayer, 31, 2000)    
   exports.coinsystem:takePlayerCoin(thePlayer, prize) 
   outputChatBox("you bought a M4.", thePlayer, 0, 255, 0, false)    
   else 
   outputChatBox("you don't have enough coins!", thePlayer, 255, 0, 0, false)    
   end 
end 
addCommandHandler("buyw", buyWeapon) 

Commands (only admins)

there are commands that can only be used by the admin group. 
  
syntax: /setcoin <playername> <amount> 
syntax: /givecoin <playername> <amount> 

EDIT: Changelog

  
[b]1.3.0[/b] - META config was removed by some bugs that caused and it was decompiled to edit your preference. 
[b]1.2.0[/b] - Some bugs was fixed. 
[b]1.1.0[/b] - Resource release. 
  

Download:

https://community.multitheftauto.com/index.php?p=resources&s=details&id=10944

Thnx :)

Edited by Guest
Link to comment
[quote name=..:D&G:..]People can compile them themselves after they edited them as they wanted. For example I cannot use the script because I cannot configure it with my gamemode :(

The script was made to work for any gamemode and also for a custom hud

I want to make it save in mysql for example, but I cannot do that as it's compiled :P

Link to comment
  • 1 month later...

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