12.04.2013, 20:54
(
Последний раз редактировалось Isolated; 13.04.2013 в 06:08.
)
Hey there!
I was browsing today, and I found this thread. Basically it was the application form for NG:RP. However, one of the statements was "Create your own /flipcoin command" So, I'd like everyone to get involved. Just to see how scripting styles vary.
Here's mine:
I also have a single player version, but it's far to simple
I was browsing today, and I found this thread. Basically it was the application form for NG:RP. However, one of the statements was "Create your own /flipcoin command" So, I'd like everyone to get involved. Just to see how scripting styles vary.
Here's mine:
pawn Код:
#define Amount (1000)
COMMAND:flipcoin(playerid, params[])
{
new flip = random(2), pid, cStr[10 char];
pid = GetClosestPlayerToPlayer(playerid);
if(!GetClosestPlayerToPlayer(playerid)) return SendClientMessage(playerid, "No player nearby.");
if(sscanf(params, "s[10]", cStr))
{
new bool: call;
if(strcmp(cStr, "heads", true)) call = true;
if(strcmp(cStr, "tails", true)) call = false;
new String[40 + MAX_PLAYER_NAME char];
new Name[MAX_PLAYER_NAME];
new pName[MAX_PLAYER_NAME];
GetPlayerName(pid, pName, MAX_PLAYER_NAME);
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
switch(flip)
{
case 0: // Heads
{
if(!call) // Incorrect :/
{
format(String, sizeof(String), "You beat %s and won Ј%d", Name, Amount);
SendClientMessage(pid, COLOR_YELLOW, String);
format(String, sizeof(String), "You lost Ј%d to %s", Amount, pName);
SendClientMessage(playerid, COLOR_YELLOW, String);
GivePlayerMoney(playerid, GetPlayerMoney(playerid) - Amount);
}
if(call)
{
format(String, sizeof(String), "You beat %s and won Ј%d", pName, Amount);
SendClientMessage(playerid, COLOR_YELLOW, String);
format(String, sizeof(String), "You lost Ј%d to %s", Amount, Name);
SendClientMessage(pid, COLOR_YELLOW, String);
GivePlayerMoney(pid, GetPlayerMoney(playerid) - Amount);
}
}
case 1: // Tails
{
if(call) // Incorrect :/
{
format(String, sizeof(String), "You beat %s and won Ј%d", Name, Amount);
SendClientMessage(pid, COLOR_YELLOW, String);
format(String, sizeof(String), "You lost Ј%d to %s", Amount, pName);
SendClientMessage(playerid, COLOR_YELLOW, String);
GivePlayerMoney(playerid, GetPlayerMoney(playerid) - Amount);
}
if(!call)
{
format(String, sizeof(String), "You beat %s and won Ј%d", pName, Amount);
SendClientMessage(playerid, COLOR_YELLOW, String);
format(String, sizeof(String), "You lost Ј%d to %s", Amount, Name);
SendClientMessage(pid, COLOR_YELLOW, String);
GivePlayerMoney(pid, GetPlayerMoney(playerid) - Amount);
}
}
}
}
else return SendClientMessage(playerid, -1, "Usage: /flipcoin heads or tails");
return 1;
}