Cops - /givelicense Command
#1

Ok, i'm trying to make it so that if you're a cop, you'll be able to give a gun license to people. But, i'm having some trouble with that already, i need it to be a Rank 4 command (i just thought of that, i didn't try that yet), but here's what i have so far, and it's shooting out errors left and right at me. What am i doing wrong?

Код:
CMD:givelicense(playerid)
{
	if(IsACop(playerid))
	{
	    if(PlayerInfo[playerid][pGunLic] == 0);//This is if they DON'T have a gun license
		{
		    PlayerInfo[playerid][pGunLic] = 1;
		    SendClientMessage(playerid, COLOR_ORANGE, "This is a test");
		    return 1;
		}
		else if
		{
		    PlayerInfo[playerid][pGunLic] = 1;
		    SendClientMessage(playerid, COLOR_ORANGE, "They already have a Gun License");
		    return 1;
		}
		else
		{
		    SendClientMessage(playerid, COLOR_RED," You are not a cop!");
		    return 1;
		}
	}
}
Reply
#2

pawn Код:
CMD:givelicense(playerid,params[])
{
    new targetid;
    if(IsACop(playerid))
    {
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,-1,"Please enter the ID of the player who you want to issue the license to.");
        if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "This player is not connected!");
        if(PlayerInfo[playerid][pGunLic] == 0)//This is if they DON'T have a gun license (There is no ; here)
        {
            PlayerInfo[targetid][pGunLic] = 1;
            SendClientMessage(targetid, COLOR_ORANGE, "You have been issued a gun license! Use it carefully.");
            SendClientMessage(playerid, 0xFFFF00FF, "You have just issued a gun license to this player.");  
        }
        else if(PlayerInfo[playerid][pGunLic] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "They already have a Gun License");
    }
    else return SendClientMessage(playerid, COLOR_RED," You are not a cop!");
    return 1;
}
EDIT: Thanks, benzo.
Reply
#3

A little fix on the above poster's code:

pawn Код:
CMD:givelicense(playerid,params[])
{
    new targetid;
    if(IsACop(playerid))
    {
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,-1,"Please enter the ID of the player who you want to issue the license to.");
        if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "This player is not connected!");
        if(PlayerInfo[playerid][pGunLic] == 0)//This is if they DON'T have a gun license (There is no ; here)
        {
            PlayerInfo[targetid][pGunLic] = 1;
            SendClientMessage(targetid, COLOR_ORANGE, "You have been issued a gun license! Use it carefully.");
            SendClientMessage(playerid, 0xFFFF00FF, "You have just issued a gun license to this player.");  
        }
        else if(PlayerInfo[playerid][pGunLic] == 1) return SendClientMessage(playerid, COLOR_ORANGE, "They already have a Gun License");
    }
    else return SendClientMessage(playerid, COLOR_RED," You are not a cop!");
    return 1;
}
Reply
#4

Oops, yeah, thanks Benzo, I changed the 'playerid' to targetid at the wrong line.
Reply
#5

Your "Else If" must contain a condition, and your "Else" statement should be part of "IsACop".

It should be like this;

pawn Код:
CMD:givelicense(playerid)
{
    if(IsACop(playerid))
    {
        if(PlayerInfo[playerid][pGunLic] == 0);//This is if they DON'T have a gun license
        {
            PlayerInfo[playerid][pGunLic] = 1;
            SendClientMessage(playerid, COLOR_ORANGE, "This is a test");
            return 1;
        }
        else
        {
            PlayerInfo[playerid][pGunLic] = 1;
            SendClientMessage(playerid, COLOR_ORANGE, "They already have a Gun License");
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED," You are not a cop!");
        return 1;
    }
}
Reply
#6

Thanks soo much, it works. I'll make sure to give you guys rep.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)