13.03.2015, 02:05
pawn Код:
CMD:sellmarijuana(playerid, params[])
{
/*if(PlayerInfo[playerid][pJob] != 2)
{
SendClientMessage(playerid, -1, "ERROR: You are not a Drug Dealer!");
return 1;
}*/
if(isnull(params)) SendClientMessage(playerid, -1, "USAGE: /selldrugs [playerid] [amount]");
else{
new tmp[5],idx; // [5] because max params lenght for id is 4 (max player id 1000) + 1 end of string and max grams is 50 (two chars)
strcat((tmp[0]=EOS,tmp),strtok(params, idx)); // cmdtext is now params ! storing playerid
new playa = strval(tmp);
if(!IsPlayerConnected(playa)) SendClientMessage(playerid, -1, "ERROR: Invalid ID.");
else if(playa == playerid) SendClientMessage(playerid, -1, "ERROR: You can't sell yourself drugs!");
else if(!ProxDetectorS(8.0, playerid, playa)) SendClientMessage(playerid, -1, "ERROR: You arn't near that player!");
else{
strcat((tmp[0]=EOS,tmp),strtok(params, idx));
if(isnull(tmp)) SendClientMessage(playerid, -1, "ERROR: Set amount!");
else{
new needed = strval(tmp);
if(!(0 < needed < 51)) SendClientMessage(playerid, -1, "ERROR: Selling Marijuana can be only in limits of 1 gram to 50 grams.");
else if(needed > PlayerInfo[playerid][pMarijuana]) SendClientMessage(playerid, -1, "ERROR: You don't have that much!");
else{
new sellpotstring[128];
format(sellpotstring, sizeof(sellpotstring), "INFO: You have gave %s %d grams of drugs.", GetPlayerNameEx(playa), needed);
SendClientMessage(playerid, -1, sellpotstring);
format(sellpotstring, sizeof(sellpotstring), "INFO: %s has just gave you %d grams of drugs.", GetPlayerNameEx(playerid), needed);
SendClientMessage(playa, -1, sellpotstring);
PlayerInfo[playa][pMarijuana] += needed;
PlayerInfo[playerid][pMarijuana] -= needed;
PlayerPlayerActionMessage(playerid,playa,15.0,"Has just gave some drugs to");
}
}
}
}
return 1;
}