26.07.2013, 19:30
Quote:
Thnx Red, or R3D
![]() But I don't use ZCMD ![]() I use the normal format and dcmd. |
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(givecash, 8, cmdtext);
return 1;
}
pawn Код:
dcm_givecash(playerid, params[])//if you are using ZCMD > credits to zeex....
{
//first we are creating some variables that will help us much
new Target, value;//we've created the target who will be givn the money and the value (how much they will take)
if(sscanf(params, "ds", Target, value)) return SendClientMessage(playerid, -1, "SYNTAX: /givecash [playerid] [ammount]");
//now, we've used sscanf to detect if the player has entered wrong syntax
// d > Target
//s > value
// -1 > color white.
GivePlayerMoney(playerid, -value);//we put the "-" to reduce the value from his money
GivePlayerMoney(Target, value);//now we are giving that value to the target
//we've done the transfer
//Additional, let's put some messages (by format)
new str[50];//added a new variable (string)
format(str, sizeof(str), "ID(%d) has given you $%d",playerid, value);
SendClientMessage(playerid, -1, str);
//read about formats , it's easy :D
return 1;
}