dcmd_givecash(playerid, params[]) { new giveplayerid, amount; if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]"); else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds"); else { GivePlayerMoney(giveplayerid, amount); GivePlayerMoney(playerid, 0 - amount); SendClientMessage(playerid, 0x00FF00AA, "Money sent"); SendClientMessage(giveplayerid, 0x00FF00AA, "Money recieved"); } return 1; }
Originally Posted by [B
|
dcmd_givecash(playerid, params[]) { new tmp[256], tmp2[256],Index; tmp = strtok(params,Index); tmp2 = strtok(params,Index); new otherid = strval(tmp); new amount = strval(tmp2); if (strlen(tmp) && strlen(tmp2)) { if (IsPlayerConnected(otherid)) { if (GetPlayerMoney(playerid) >= amount) { new string[256], string2[256], name[MAX_PLAYER_NAME], oname[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(otherid, oname, sizeof(oname)); GivePlayerMoney(playerid, GetPlayerMoney(playerid)-amount); GivePlayerMoney(otherid, amount); format(string, sizeof(string), "You have sent %s $%d.", oname, amount); format(string2, sizeof(string2), "%s has sent you $%d.", name, amount); SendClientMessage(playerid, COLOR, string); SendClientMessage(otherid, COLOR, string2); } else { SendClientMessage(playerid, COLOR, "You dont have that amount of cash."); } } else { SendClientMessage(playerid, COLOR, "Invalid player id."); } } else { SendClientMessage(playerid, COLOR, "USAGE: /givecash [playerid] [amount]"); } }