03.01.2011, 13:37
Can someone please give me a code script for /pay!!!!!!
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
dcmd_pay(playerid, params[])
{
new idx;
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
}else{
new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[150], pid;
pid = strval(tmp);
if(!IsPlayerConnected(pid)){
SendClientMessage(playerid, 0x801818AA, "Invalid player");
return 1;
}
tmp = strrest(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
}
new amount = strval(tmp);
if(GetPlayerMoney(playerid) < amount){
SendClientMessage(playerid, 0x801818AA, "You don't have enough money");
}else{
GetPlayerName(playerid, pname1, sizeof(pname1));
GetPlayerName(pid, pname2, sizeof(pname2));
format(string, sizeof(string), "*%s gave %s %d$", pname1, pname2, amount);
SendClientMessageToAll(0x801818AA, string);
GivePlayerMoney(pid, amount);
GivePlayerMoney(playerid, -amount);
}
}
return 1;
}
stock strrest(const string[], index)
{
new length = strlen(string),offset = index,result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
pawn Код:
|
dcmd(pay,3,cmdtext);
public OnPlayerCommandText(playerid, cmdtext[])
{
// ADD the line here
}