/givegunlicense command help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /givegunlicense command help (
/showthread.php?tid=366137)
/givegunlicense command help -
Luke_James - 05.08.2012
I wrote this code earlier and I'd like someone to check it and give me feedback..
pawn Код:
cmd:givegunlicense(playerid,params[])
{
if(IsACop(playerid))
{
if(OnDuty[playerid] != 1)
}
SendClientMessage(playerid, COLOR_GREY, "You are not on-duty!");
return 1;
}
if(PlayerInfo[playerid] [pRank < 6)
{
SendClientMessage(playerid, COLOR_GREY, "You need to be a Sergeant I or higher!");
return 1;
}
else if(strcmp(x_nr,"GunLicense",false) == 0)
{
new string[128];
format(string, sizeof(string), "*You have given a weapons license to %s.", PlayerNameEx(giveplayerid));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "*You have received a weapons license from %s.", PlayerNameEx(playerid));
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
PlayerInfo[giveplayerid] [pGunLic] = 1;
return 1;
}
Would this work?
Re: /givegunlicense command help -
The__ - 05.08.2012
Did you test this ?
EDIT:
pawn Код:
cmd:givegunlicense(playerid,params[])
{
if(IsACop(playerid))
{
if(OnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GREY, "You are not on-duty!");
return 1;
}
if(PlayerInfo[playerid] [pRank < 6)
{
SendClientMessage(playerid, COLOR_GREY, "You need to be a Sergeant I or higher!");
return 1;
}
new _gP = GetClosestPlayer(playerid);
new szMsg[128];
if(sscanf(params, "u", _gP)) return SendClientMessage( playerid, COLOR_WHITE, "/givegunlicnse [id/name]" );
if(GetDistanceBetweenPlayers(playerid,_gP) < 2)
{
format(szMsg, sizeof(szMsg), "*You have given a weapons license to %s.", PlayerNameEx(_gP));
SendClientMessage(playerid, COLOR_LIGHTBLUE, szMsg);
format(szMsg, sizeof(szMsg), "*You have received a weapons license from %s.", PlayerNameEx(playerid));
SendClientMessage(_gP, COLOR_LIGHTBLUE, szMsg);
PlayerInfo[_gP] [pGunLic] = 1;
return 1;
}
}
}
forward GetClosestPlayer(p1);
public GetClosestPlayer(p1)
{
new Float:dis,Float:dis2,player;
player = -1;
dis = 99999.99;
foreach (Player,x) {
if(IsPlayerConnected(x)) {
if(x != p1) {
dis2 = GetDistanceBetweenPlayers(x,p1);
if(dis2 < dis && dis2 != -1.00) {
dis = dis2;
player = x;
}
}
}
}
return player;
}
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2)) {
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
I've completley edited it.
Re: /givegunlicense command help -
DaRealShazz - 05.08.2012
Try compiling it yourself first.
Also, if you want help, try indenting.
People don't like a mess.