21.08.2014, 10:36
I'm looking for /givegun command, /givegun [playerid] [ammo], im using zcmd and scnaff.
Any TUT? Searched but didn't find.
Any TUT? Searched but didn't find.
#include <ocmd>
ocmd:givegun(playerid, params[])
{
new id, wid, wam;
if(sscanf(params, "uii", id, wid, wam))return SendClientMessage(playerid, -1, "USAGE: /givegun [Playername/ID] [WeaponID] [Ammu]");
if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, "Error:The player does not exist!");
GivePlayerGun(id, wid, wam);
return 1;
}
CMD:givegun(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new target, gun, string[128];
if(sscanf(params, "ud", target, gun))
{
SendClientMessage(playerid, COLOR_GREY, "Usage: /givegun <playerid> <gun>");
return 1;
}
if(gun < 1 || gun > 47) { SendClientMessage(playerid, COLOR_GREY, "Don't go below 1 or above 47."); return 1; }
if(IsPlayerConnected(target))
{
if(target != INVALID_PLAYER_ID && gun <= 20 || gun >= 22)
{
GivePlayerValidWeapon(target, gun, 50000);
format(string, sizeof(string), "Admin %s has given you a weapon.", GetName(playerid));
SendClientMessage(target, COLOR_GREY, string);
format(string, sizeof(string), "You have given %s a weapon.", GetName(target));
SendClientMessage(playerid, COLOR_GREY, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
return 1;
}
return 1;
}
if(strcmp(x_nr,"gun",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give gun [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);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
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 gun [playerid/PartOfName] [amount]");
return 1;
}
new sammo = GetPlayerAmmo(playerid);
new weapon = GetPlayerWeapon(playerid);
new ammo = strval(tmp);
if(ammo > sammo)
{
SendClientMessage(playerid, COLOR_GREY, "* You don't have so many bullets.");
return 1;
}
SafeGivePlayerWeapon(giveplayerid, weapon, ammo);
SafeGivePlayerWeapon(playerid, weapon, -ammo);
if(PlayerInfo[playerid][pSex] == 1)
{
format(string, sizeof(string), "* %s takes out his weapon and hands it to %s with %d bullets.", sendername, giveplayer, ammo);
}
else
{
format(string, sizeof(string), "* %s takes out her weapon and hands it to %s with %d bullets.", sendername, giveplayer, ammo);
}
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 gun %s %d",d,m,y1,h,mi,s,sendername,giveplayer, ammo);
CommandLog(string);
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Player is Offline!");
return 1;
}
}