Posts: 331
Threads: 84
Joined: Feb 2015
Reputation:
0
Hi !
I want to make a bid system for houses.
So, when i start the bid, players will type /bid amount to bid for it.
I don't know how can I detect after 2 minutes which offered the highest amount for the bid.
I use
/bid amount, and variable:
PlayerInfo[playerid][pBidAmount] = amount;
Posts: 775
Threads: 78
Joined: Dec 2014
Here:
PHP код:
new HighestBid,
BidLeader,
AuctionStarted;
forward BidTimer();
CMD:startauction(playerid)
{
AuctionStarted = 1;
BidLeader = -1;
HighestBid= -1;
SetTimer("BidTimer", 120000, false); //Two minutes
SendClientMessage(playerid, -1, "Auction has started! Use (/bid)");
return 1;
}
public BidTimer()
{
AuctionStarted = 0;
new string[128];
format(string, 128, "The winner was ID %i with their bet of $%i", BidLeader, HighestBid);
SendClientMessageToAll(-1, string);
//Do whatever you want with BidLeader as playerid.
}
CMD:bid(playerid, params[])
{
if(AuctionStarted != 1) return SendClientMessage(playerid, -1, "There's not auction.");
new bid;
if(!sscanf(params, "i", bid))
{
if(bid > HighestBid)
{
BidLeader = playerid;
HighestBid = bid;
}
else
{
new string[128];
format(string, 128, "Sorry, you made a too low bid, current bid is: $%i by ID %i", HighestBid, BidLeader);
SendClientMessage(playerid, -1, string);
}
}
else
SendClientMessage(playerid, -1, "USAGE: /bid [value]");
return 1;
}
Not tested and wroten direct in web.