SA-MP Forums Archive
Is it possible to replace 1 with "Yes"? - 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: Is it possible to replace 1 with "Yes"? (/showthread.php?tid=461970)



Is it possible to replace 1 with "Yes"? - Beckett - 04.09.2013

Is it possible to replace the "1" with "Yes"?
Код:
CMD:showid(playerid, params[])
{
    new Player;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You are not a RCON Admin!");
    else if (sscanf(params, "u", Player)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[INFO] /showid [Playerid/PartOfName");
    else if (Player == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED2, "[INFO]{FFFFFF}: Invalid ID.");
    else
    {
		new string[125];
		SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
	 	format(string,sizeof(string),"|| Name : %s || || Gun License : %d ||",RemoveUnderScore(playerid),pInfo[playerid][GunLic]);
		SendClientMessage(Player,COLOR_GRAY,string);
	 	if (pInfo[playerid][LSPD] >= 1)
	 	{
	 	    SendClientMessage(Player,COLOR_GRAY,"Organization: Los Santos Police Department");
	 	    SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
		}

    }
    return 1;
}
Thanks in advance.


Re: Is it possible to replace 1 with "Yes"? - WopsS - 04.09.2013

Replace with "Yes" at Gun License?

If yes, take this:
pawn Код:
CMD:showid(playerid, params[])
{
    new Player;
    new gunlicensetext[5];
    if(pInfo[playerid][GunLic] == 1)
    {
        gunlicensetext = "Yes";
    }
    else
    {
        gunlicensetext = "No";
    }
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You are not a RCON Admin!");
    else if (sscanf(params, "u", Player)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[INFO] /showid [Playerid/PartOfName");
    else if (Player == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED2, "[INFO]{FFFFFF}: Invalid ID.");
    else
    {
        new string[125];
        SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
        format(string,sizeof(string),"|| Name : %s || || Gun License : %s ||",RemoveUnderScore(playerid),gunlicensetext);
        SendClientMessage(Player,COLOR_GRAY,string);
        if (pInfo[playerid][LSPD] >= 1)
        {
            SendClientMessage(Player,COLOR_GRAY,"Organization: Los Santos Police Department");
            SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
        }

    }
    return 1;
}



Re: Is it possible to replace 1 with "Yes"? - Konstantinos - 04.09.2013

An example:
pawn Код:
new
    var = 1
;
printf( "var: \"%s\"", ( var == 1 ) ? ( "Yes" ) : ( "No" ) );
It will print var: "Yes"

So, it goes like:
pawn Код:
format(string,sizeof(string),"|| Name : %s || || Gun License : %s ||",RemoveUnderScore(playerid), ( pInfo[playerid][GunLic] == 1 ) ? ( "Yes" ) : ( "No" ) );



Re: Is it possible to replace 1 with "Yes"? - TonyII - 04.09.2013

pawn Код:
new str[30];
    switch(pInfo[playerid][GunLic])
    {
        case 1: str = "Yes";
        default: str= "No";
    }
Then replace pInfo[playerid][GunLic] thats coming after RemoveUnderScore with str


Re: Is it possible to replace 1 with "Yes"? - Jessyy - 04.09.2013

... "Yes" at Gun License?
Код:
format(string,sizeof(string),"|| Name : %s || || Gun License : %s ||",RemoveUnderScore(playerid), (pInfo[playerid][GunLic]) ? ("Yes") : ("No"));
if this is not what you wanted... sorry it's hard to read the minds of others !!!


Re: Is it possible to replace 1 with "Yes"? - Beckett - 04.09.2013

Quote:
Originally Posted by WopsS
Посмотреть сообщение
Replace with "Yes" at Gun License?

If yes, take this:
pawn Код:
CMD:showid(playerid, params[])
{
    new Player;
    new gunlicensetext[128];
    if(pInfo[playerid][GunLic] == 1)
    {
        gunlicensetext = "Yes";
    }
    else
    {
        gunlicensetext = "No";
    }
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You are not a RCON Admin!");
    else if (sscanf(params, "u", Player)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[INFO] /showid [Playerid/PartOfName");
    else if (Player == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED2, "[INFO]{FFFFFF}: Invalid ID.");
    else
    {
        new string[125];
        SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
        format(string,sizeof(string),"|| Name : %s || || Gun License : %d ||",RemoveUnderScore(playerid),gunlicensetext);
        SendClientMessage(Player,COLOR_GRAY,string);
        if (pInfo[playerid][LSPD] >= 1)
        {
            SendClientMessage(Player,COLOR_GRAY,"Organization: Los Santos Police Department");
            SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
        }

    }
    return 1;
}
Thats what I exactly wanted but it doesn't state "Yes" it just defines a random number.
http://prntscr.com/1pbbya


Re: Is it possible to replace 1 with "Yes"? - WopsS - 04.09.2013

sorry, take this:

pawn Код:
CMD:showid(playerid, params[])
{
    new Player;
    new gunlicensetext[5];
    if(pInfo[playerid][GunLic] == 1)
    {
        gunlicensetext = "Yes";
    }
    else
    {
        gunlicensetext = "No";
    }
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You are not a RCON Admin!");
    else if (sscanf(params, "u", Player)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[INFO] /showid [Playerid/PartOfName");
    else if (Player == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED2, "[INFO]{FFFFFF}: Invalid ID.");
    else
    {
        new string[125];
        SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
        format(string,sizeof(string),"|| Name : %s || || Gun License : %s ||",RemoveUnderScore(playerid),gunlicensetext);
        SendClientMessage(Player,COLOR_GRAY,string);
        if (pInfo[playerid][LSPD] >= 1)
        {
            SendClientMessage(Player,COLOR_GRAY,"Organization: Los Santos Police Department");
            SendClientMessage(Player,COLOR_LIGHTBLUE,"====================================================");
        }

    }
    return 1;
}



Re: Is it possible to replace 1 with "Yes"? - Konstantinos - 04.09.2013

Because:
pawn Код:
Gun License : %d
while it should be:
pawn Код:
Gun License : %s
However, using ternary operator is far easier..


Re: Is it possible to replace 1 with "Yes"? - WopsS - 04.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Because:
pawn Код:
Gun License : %d
while it should be:
pawn Код:
Gun License : %s
However, using ternary operator is far easier..
Yes I know, I forgot to change there ...


Re: Is it possible to replace 1 with "Yes"? - Beckett - 04.09.2013

Thank you guys ^^ appreciated!