Command help
#1

Hei , i am new there , before present myself , i want a little help ( i am newbie in scripting ) .

I made these days one command that return to player his licenses status. I want to know how i can make an command like /showlicenses [id of player] for eg , that show to a cop if i have valid licenses.

Код:
CMD:identification(playerid, params[])
{
	if(playerVariables[playerid][pCarLic] == 0)
	{
			SendClientMessage(playerid,COLOR_WHITE, "|__________________ACTS INFO__________________|");
			SendClientMessage(playerid,COLOR_GREY, "Driver License: No");
	
	}
	else
	{
			SendClientMessage(playerid,COLOR_WHITE, "|__________________ACTS INFO__________________|");
			SendClientMessage(playerid,COLOR_GREY, "Driver License: Yes");

	}
	if(playerVariables[playerid][pPassport] == 0)
	{
			SendClientMessage(playerid,COLOR_GREY, "Passport: No");

	}
	else
	{
			SendClientMessage(playerid,COLOR_GREY, "Passport: Yes");

	}

	
	return 1;
}
Reply
#2

pawn Код:
CMD:showlicense(playerid, params[])
{
    new OtherPlayer;
   
    sscanf(params, "i", OtherPlayer) {
        if(playerVariables[playerid][pCarLic] == 0)
        {
            SendClientMessage(OtherPlayer, COLOR_WHITE, "|__________________ACTS INFO__________________|");
            SendClientMessage(OtherPlayer, COLOR_GREY, "Driver License: No");
        }
        else
        {
            SendClientMessage(OtherPlayer, COLOR_WHITE, "|__________________ACTS INFO__________________|");
            SendClientMessage(OtherPlayer, COLOR_GREY, "Driver License: Yes");
        }
        if(playerVariables[playerid][pPassport] == 0)
        {
            SendClientMessage(OtherPlayer, COLOR_GREY, "Passport: No");
        }
        else
        {
            SendClientMessage(OtherPlayer, COLOR_GREY, "Passport: Yes");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/showlicense <OtherPlayer>\"");
    }
    return 1;
}
You can see if this works, I'm not a PAWN guru, so no guarantees!
Reply
#3

thanks for the answer . i will check it tomorrow.
Reply
#4

Quote:
Originally Posted by Stevee
Посмотреть сообщение
pawn Код:
CMD:showlicense(playerid, params[])
{
    new OtherPlayer;
   
    sscanf(params, "i", OtherPlayer) {
        if(playerVariables[playerid][pCarLic] == 0)
        {
            SendClientMessage(OtherPlayer, COLOR_WHITE, "|__________________ACTS INFO__________________|");
            SendClientMessage(OtherPlayer, COLOR_GREY, "Driver License: No");
        }
        else
        {
            SendClientMessage(OtherPlayer, COLOR_WHITE, "|__________________ACTS INFO__________________|");
            SendClientMessage(OtherPlayer, COLOR_GREY, "Driver License: Yes");
        }
        if(playerVariables[playerid][pPassport] == 0)
        {
            SendClientMessage(OtherPlayer, COLOR_GREY, "Passport: No");
        }
        else
        {
            SendClientMessage(OtherPlayer, COLOR_GREY, "Passport: Yes");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/showlicense <OtherPlayer>\"");
    }
    return 1;
}
You can see if this works, I'm not a PAWN guru, so no guarantees!
Why would you use the i specifier instead of the u?
pawn Код:
CMD:showlicenses(playerid, params[])
{
    new
        targetid,
        string[128],
        name[MAX_PLAYER_NAME]
    ;
    if(sscanf(params, "u", targetid))
    {
        return SendClientMessage(playerid, -1, "USAGE: /showlicenses [playerid/PartOfName]");
    }
    if(targetid == INVALID_PLAYER_ID)
    {
        return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
    }
    GetPlayerName(playerid, name, 24);
    format(string, 128, "|_________________%s's Licenses__________________|", name);
    SendClientMessage(targetid, COLOR_GREY, string);
    if(playerVariables[playerid][pCarLic] == 0)
    {
        SendClientMessage(targetid,COLOR_GREY, "Driver License: No");
    }
    else
    {
        SendClientMessage(targetid,COLOR_GREY, "Driver License: Yes");
    }
    if(playerVariables[playerid][pPassport] == 0)
    {
        SendClientMessage(targetid,COLOR_GREY, "Passport: No");
    }
    else
    {
        SendClientMessage(targetid,COLOR_GREY, "Passport: Yes");
    }
    return 1;
}
Reply
#5

I also have another idea but i am limited by my pawno knowledge . for example i am a cop ( i have an if for that ) , and by a command /confiscate (playerid) i want to set playervariable carlic to 0 if it's
1 . i don't know how to do with playerid ... or i can use same format like in last post ?
Reply
#6

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Why would you use the i specifier instead of the u?
I don't know, I've always thought using the ID saves hassle really

Quote:
Originally Posted by christiand
Посмотреть сообщение
I also have another idea but i am limited by my pawno knowledge . for example i am a cop ( i have an if for that ) , and by a command /confiscate (playerid) i want to set playervariable carlic to 0 if it's
1 . i don't know how to do with playerid ... or i can use same format like in last post ?
I'm not sure how you'd set your player variable, but if you do I'll leave you with a basic starting code

pawn Код:
CMD:confiscate(playerid, params[])
{
    new OtherPlayer, PlayersName[24], Message[128];

    sscanf(params, "u", OtherPlayer)
    {
        if(put your cop checking statement here)
        {
            if(playerVariables[OtherPlayer][pCarLic] == 0)
            {
                SendClientMessage(playerid, COLOR_WHITE, "Player doesn't have a license");
            }
            else
            {
                GetPlayerName(OtherPlayer, PlayersName, sizeof(PlayersName));
                // Run your player variable setting code here
                format(Message, sizeof(Message), "You've confiscated %s's driving license", PlayersName);
                SendClientMessage(playerid, COLOR_WHITE, Message);
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000AA, "You are not a cop!");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/confiscate <OtherPlayer>\"");
    }
    return 1;
}
Once again, I'm not a PAWN guru, no guarantee that the code will work.

replace

Код:
	    if(put your cop checking statement here)
with your cop checking if statement
Reply
#7

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Why would you use the i specifier instead of the u?
The 'i' specifier is faster than the 'u' specifier but it does not allow you to enter names via commands (which almost nobody does, they usually use IDs). If you want to save a little bit of speed and lose a not-so-needed function, then you should use 'i' instead of 'u'.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)