02.02.2011, 17:28
Just convert it to sccanf + zcmd, please.
pawn Код:
if(strcmp(cmd, "/give", true) == 0) // by Cuervo
{
if(IsPlayerConnected(playerid))
{
new x_nr[24];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give [name] [playerid/PartOfName] ([ammount])");
SendClientMessage(playerid, COLOR_WHITE, "Available names: drugs, rope");
return 1;
}
if(strcmp(x_nr,"drugs",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give drugs [playerid/PartOfName] [amount]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(giveplayerid,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
{
SendClientMessage(playerid, COLOR_GRAD1, "** Player is not near you!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give drugs [playerid/PartOfName] [amount]");
return 1;
}
new dammount;
dammount = strval(tmp);
if(dammount > PlayerInfo[playerid][pDrugs]) { SendClientMessage(playerid, COLOR_GREY, " You don't have so many drugs."); return 1; }
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
PlayerInfo[playerid][pDrugs] -= dammount;
PlayerInfo[giveplayerid][pDrugs] += dammount;
if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* %s takes out his sack with drugs and hands it to %s.", sendername, giveplayer); }
else { format(string, sizeof(string), "* %s takes out her sack with drugs and hands it to %s.", sendername, giveplayer); }
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
new y1, m, d;
new h,mi,s;
getdate(y1,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /give drugs %s %d",d,m,y1,h,mi,s,sendername,giveplayer, dammount);
CommandLog(string);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Player is Offline!");
return 1;
}
}
else if(strcmp(x_nr,"rope",true) == 0)
{
if(Rope[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GRAD1, " You don't have a rope to give!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give rope [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(ProxDetectorS(5, playerid, giveplayerid))
{
if(Rope[giveplayerid] > 4)
{
SendClientMessage(playerid, COLOR_GREY, " Player has enough ropes with him !");
return 1;
}
Rope[playerid]--;
Rope[giveplayerid]++;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new y, m, d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /give rope %s",d,m,y,h,mi,s,sendername,giveplayer);
CommandLog(string);
format(string, sizeof(string), "* %s hands a rope to %s.", sendername ,giveplayer);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "** Player is not near you !");
return 1;
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give [name] [playerid/PartOfName] ([ammount])");
SendClientMessage(playerid, COLOR_WHITE, "Available names: drugs, gun, vehkey, hirekey, rope");
return 1;
}
}
return 1;
}