02.02.2011, 17:47
I made it quickly , and MAY be not working because it was not written well, it's hard to read, so you can rescript it yourself it doesn't work and stop being a lazy fuck.
pawn Код:
CMD:give(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
new x_nr;
if (sscanf(params,"s",x_nr))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /give [name] [playerid/PartOfName] ([ammount])");
SendClientMessage(playerid, COLOR_WHITE, "Available names: drugs, rope");
return 1;
}
if(strcmp(params,"drugs",true) == 0)
{
new id, ammount;
if(sscanf(params,"ri",id, ammount))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give drugs [playerid/PartOfName] [amount]");
return 1;
}
if(IsPlayerConnected(id))
{
if(id != INVALID_PLAYER_ID)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(id,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
{
SendClientMessage(playerid, COLOR_GRAD1, "** Player is not near you!");
return 1;
}
if(sscanf(params,"ri",id, ammount)
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give drugs [playerid/PartOfName] [amount]");
return 1;
}
if(ammount > PlayerInfo[playerid][pDrugs]) { SendClientMessage(playerid, COLOR_GREY, " You don't have so many drugs."); return 1; }
new togivename[28], givername[28];
GetPlayerName(id, togivename, sizeof(togivename));
GetPlayerName(playerid, givername, sizeof(givername));
PlayerInfo[playerid][pDrugs] -= ammount;
PlayerInfo[id][pDrugs] += ammount;
if(PlayerInfo[playerid][pSex] == 1) { format(string, sizeof(string), "* %s takes out his sack with drugs and hands it to %s.", givername, togiveplayer); }
else { format(string, sizeof(string), "* %s takes out her sack with drugs and hands it to %s.", givername, togiveplayer); }
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(params,"rope",true) == 0)
{
if(Rope[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GRAD1, " You don't have a rope to give!");
return 1;
}
new id;
if(sscanf(params,"r",id))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give rope [playerid/PartOfName]");
return 1;
}
if(IsPlayerConnected(id))
{
if(id != INVALID_PLAYER_ID)
{
if(ProxDetectorS(5, playerid, id))
{
if(Rope[giveplayerid] > 4)
{
SendClientMessage(playerid, COLOR_GREY, " Player has enough ropes with him !");
return 1;
}
Rope[playerid]--;
Rope[id]++;
GetPlayerName(id, 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,id);
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;
}