SA-MP Forums Archive
Control Structure - 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: Control Structure (/showthread.php?tid=655497)



Control Structure - Jing_Chan - 22.06.2018

pawn Код:
if(PlayerData[playerid][pFactionRank] > FactionData[PlayerData[playerid][pFaction]][factionEditrank] || PlayerData[playerid][pAdmin] < 5)
        return SendClientMessage(playerid, COLOR_ADM, "ACCESS DENIED:{FFFFFF} Your rank doesn't have permission to do this.");
For some reason, even as above level 5 admin it doesn't let me do the command? I'm obviously failing to see the obvious, can someone help please.


Re: Control Structure - GTLS - 22.06.2018

Try this.

PHP код:
if((PlayerData[playerid][pFactionRank] > FactionData[PlayerData[playerid][pFaction]][factionEditrank]) && PlayerData[playerid][pAdmin] < 5)
        return 
SendClientMessage(playeridCOLOR_ADM"ACCESS DENIED:{FFFFFF} Your rank doesn't have permission to do this."); 



Re: Control Structure - Jing_Chan - 22.06.2018

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Try this.

PHP код:
if((PlayerData[playerid][pFactionRank] > FactionData[PlayerData[playerid][pFaction]][factionEditrank]) && PlayerData[playerid][pAdmin] < 5)
        return 
SendClientMessage(playeridCOLOR_ADM"ACCESS DENIED:{FFFFFF} Your rank doesn't have permission to do this."); 
Wouldn't that require both structures to be correct in order to work?

Код:
&&	and	if (Left && Right)



Re: Control Structure - Exhibit - 22.06.2018

If this is a command show us the full code.


Re: Control Structure - Mike861 - 22.06.2018

Try PlayerData[playerid] [pAdmin] <= 5


Re: Control Structure - Jing_Chan - 22.06.2018

Quote:
Originally Posted by Exhibit
Посмотреть сообщение
If this is a command show us the full code.
pawn Код:
CMD:configfaction(playerid, params[])
{
    if(!PlayerData[playerid][pFaction])
        return SendClientMessage(playerid, COLOR_ADM, "ERROR: You aren't in a faction.");

    if(PlayerData[playerid][pFactionRank] > FactionData[PlayerData[playerid][pFaction]][factionEditrank] || PlayerData[playerid][pAdmin] < 5)
        return SendClientMessage(playerid, COLOR_ADM, "ACCESS DENIED:{FFFFFF} Your rank doesn't have permission to do this.");

    ShowYourFactionMenu(playerid);
    return 1;
}



Re: Control Structure - Exhibit - 22.06.2018

PHP код:
CMD:configfaction(playeridparams[])
{
    if(!
PlayerData[playerid][pFaction])
        return 
SendClientMessage(playeridCOLOR_ADM"ERROR: You aren't in a faction.");
    if(
PlayerData[playerid][pFactionRank] > FactionData[PlayerData[playerid][pFaction]][factionEditrank])
        return 
SendClientMessage(playeridCOLOR_ADM"ACCESS DENIED:{FFFFFF} Your rank doesn't have permission to do this.");
        if(
PlayerData[playerid][pAdmin] < 5) return SendClientMessage(playeridCOLOR_ADM"ACCESS DENIED:{FFFFFF} Your rank doesn't have permission to do this. ADMIN");
    
ShowYourFactionMenu(playerid);
    return 
1;

try this.


Re: Control Structure - jasperschellekens - 22.06.2018

Are you sure that this:
PlayerData[playerid][pAdmin]
Holds the correct value?
Try printing it to be sure, your code looks ok. It should work

Quote:
Originally Posted by Exhibit
Посмотреть сообщение
try this.
Im pretty sure the topic starter knows this method. He clearly doesn't want to do it this way hence he is using || (means or in an if-statement).
The way you showed him is repeating code and his method using ||/or should work.


Re: Control Structure - Jing_Chan - 22.06.2018

Quote:
Originally Posted by jasperschellekens
Посмотреть сообщение
Are you sure that this:
PlayerData[playerid][pAdmin]
Holds the correct value?
Try printing it to be sure, your code looks ok. It should work


Im pretty sure the topic starter knows this method. He clearly doesn't want to do it this way hence he is using || (means or in an if-statement).
The way you showed him is repeating code and his method using ||/or should work.
It does hold the correct value. I'm not sure why it isn't working - trying to figure ways around it.


Re: Control Structure - GTLS - 24.06.2018

Quote:
Originally Posted by Jing_Chan
Посмотреть сообщение
Wouldn't that require both structures to be correct in order to work?

Код:
&&	and	if (Left && Right)
Yes and thats what you should achieve here. If Player is admin less than 5 and he is also less than edit rank, error shows up.