13.09.2013, 09:21
Well guys I spend some time to script this it's /frisk command I have to add few things but ok, for start tell me if this will work (I didn't had nobody to test with me cuz I can't IP forward and open server to public)
So will this code work or are here any bugs or anything that I can make better ?
I tested it on my self and for now is all okay BUT:
Will this work?
And how can I add that player can't frisk himself ? so player can't enter his OWN ID ?
Thanks for help in advance
So will this code work or are here any bugs or anything that I can make better ?
pawn Код:
CMD:frisk(playerid, params[])
{
new
id,
Slot,
Weapon,
Ammo,
CNT,
X,
Str[128],
Str2[64],
WN[32],
Float:x,
Float:y,
Float:z,
Name[MAX_PLAYER_NAME];
GetPlayerName(id, Name, sizeof(Name));
GetPlayerPos(playerid, Float:x, Float:y, Float:z); // Your position
if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: \"/frisk [playerid]\"");
else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Invalid player ID");
else if (IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, 0xFF0000AA, "That player is in vehicle");
else if (!IsPlayerInRangeOfPoint(id, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
else
{
format(Str2, sizeof(Str2), "* Items you can find on %s are:", Name);
SendClientMessage(playerid, COLOR_YELLOW, Str2);
for(Slot = 0; Slot < 14; Slot++)
{
GetPlayerWeaponData(id, Slot, Weapon, Ammo);
if( Ammo != 0 && Weapon != 0)
CNT++;
}
if(CNT < 1) return SendClientMessage(playerid,0xFF0000AA,"No weapons found");
if(CNT >= 1)
{
for (Slot = 0; Slot < 14; Slot++)
{
GetPlayerWeaponData(id, Slot, Weapon, Ammo);
if( Ammo != 0 && Weapon != 0)
{
GetWeaponName(Weapon,WN, sizeof(WN));
if(Ammo == 65535 || Ammo == 1)
format(Str,sizeof(Str),"%s%s (1)",Str, WN);
else format(Str,sizeof(Str),"%s%s (%d)",Str, WN, Ammo);
X++;
if(X >= 5)
{
SendClientMessage(playerid, 0xFF0000AA, Str);
X = 0;
format(Str, sizeof(Str), "");
}
else format(Str, sizeof(Str), "%s, ", Str);
}
}
if(X <= 4 && X > 0)
{
Str[strlen(Str)-3] = '.';
SendClientMessage(playerid, 0xFF0000AA, Str);
}
}
}
return 1;
}
Will this work?
pawn Код:
else if (!IsPlayerInRangeOfPoint(id, 5.0, x, y, z)) return SendClientMessage(playerid, 0xFF0000AA, "You are not near that player");
Thanks for help in advance
