Advertisement
Shiny_

Untitled

Sep 29th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. if(strcmp(cmd, "/givecash") == 0) {
  2.     cmd = strtok(NULL, " ");
  3.  
  4.     if(cmd == 0 || !strlen(cmd)) {
  5.       SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
  6.       return true;
  7.     }
  8.     giveplayerid = atoi(cmd);
  9.  
  10.     cmd = strtok(NULL, " ");
  11.     if(cmd == 0 || !strlen(cmd)) {
  12.       SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
  13.       return true;
  14.     }
  15.      moneys = atoi(cmd);
  16.  
  17.     if (IsPlayerConnected(giveplayerid)) {
  18.       GetPlayerName(giveplayerid, giveplayer, MAX_PLAYER_NAME);
  19.       GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
  20.       playermoney = GetPlayerMoney(playerid);
  21.       if (moneys > 0 && playermoney >= moneys) {
  22.         GivePlayerMoney(playerid, (0 - moneys));
  23.         GivePlayerMoney(giveplayerid, moneys);
  24.         sprintf(string, "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
  25.         SendClientMessage(playerid, COLOR_YELLOW, string);
  26.         sprintf(string, "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
  27.         SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  28.         ServerLog::Printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
  29.       }
  30.       else {
  31.         SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
  32.       }
  33.     }
  34.     else {
  35.       sprintf(string, "%d is not an active player.", giveplayerid);
  36.       SendClientMessage(playerid, COLOR_YELLOW, string);
  37.     }
  38.     return true;
  39.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement