SA-MP Forums Archive
Help here a bit - 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: Help here a bit (/showthread.php?tid=332373)



Help here a bit - N0FeaR - 07.04.2012

I want so you must be near the player to use this cmd can someone help me?

pawn Код:
}
    if(strcmp(cmd, "/giveweaponlicense", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pFaction] == 1 && PlayerInfo[playerid][pRank] <= 3 || PlayerInfo[playerid][pAdministrator] > 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /giveweaponlicense [playerid/partofname]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        new wep1[128];
                        PlayerInfo[giveplayerid][pWepLic] = 1;
                        format(wep1, sizeof(wep1), "gives %s a weapon license.",GetPlayerNameEx(giveplayerid));
                        PlayerActionMessage(playerid,15.0,wep1);
                        new give1[128];
                        format(give1, sizeof(give1), "You have given %s a weapon license.", GetPlayerNameEx(giveplayerid));
                        SendClientMessage(playerid, COLOR_WHITE, give1);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "Playerid is not an active playerid");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "You are not a police officer!");
            }
        }
        return 1;



Re: Help here a bit - Boooth - 08.04.2012

Here's a stock for ya.

Код:
stock IsPlayerInRangeOfPlayer(playerid, playerid2, Float: radius) {

	new
		Float:Floats[3];

	GetPlayerPos(playerid2, Floats[0], Floats[1], Floats[2]);
	return IsPlayerInRangeOfPoint(playerid, radius, Floats[0], Floats[1], Floats[2]);
}
Enjoy


Re: Help here a bit - [DOG]irinel1996 - 08.04.2012

Try now, with this:
pawn Код:
if(strcmp(cmd, "/giveweaponlicense", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pFaction] == 1 && PlayerInfo[playerid][pRank] <= 3 || PlayerInfo[playerid][pAdministrator] > 0)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /giveweaponlicense [playerid/partofname]");
                    return 1;
                }
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    new Float:NearYou[3];
                    GetPlayerPos(giveplayerid, NearYou[0], NearYou[1], NearYou[2]);
                    if(!IsPlayerInRangeOfPoint(playerid, 1.0, NearYou[0], NearYou[1], NearYou[2])) //1.0 is the range, try changing it if you don't like 1.0
{
SendClientMessage(playerid,-1,"You must be near the player!");
return 1;
}
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        new wep1[128];
                        PlayerInfo[giveplayerid][pWepLic] = 1;
                        format(wep1, sizeof(wep1), "gives %s a weapon license.",GetPlayerNameEx(giveplayerid));
                        PlayerActionMessage(playerid,15.0,wep1);
                        new give1[128];
                        format(give1, sizeof(give1), "You have given %s a weapon license.", GetPlayerNameEx(giveplayerid));
                        SendClientMessage(playerid, COLOR_WHITE, give1);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "Playerid is not an active playerid");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "You are not a police officer!");
            }
        }
        return 1;
}
It should work, best regards!


Re: Help here a bit - Boooth - 08.04.2012

You just gave him a load of unnessacary code, he can make his script a hell of a lot more efficient with the stock.


Re: Help here a bit - N0FeaR - 08.04.2012

Thanks, is was long time when i script so i forgot, but thanks man.


Re: Help here a bit - [DOG]irinel1996 - 08.04.2012

Quote:
Originally Posted by Boooth
Посмотреть сообщение
You just gave him a load of unnessacary code, he can make his script a hell of a lot more efficient with the stock.
Maybe faster, but the efficiency is the same.

No problem, you're welcome.

Best regards!