How to write in code "if it isn't greater than or equal to"..
#1

How would I write in code "if it isn't greater than or equal to"?

For example:

if(pInfo[playerid][Adminlevel] !>= 1)

if the player is NOT greater than or equal to.. return CODE

No idea how to script this haha
Reply
#2

if(pInfo[playerid][Adminlevel] < 1)


or maybe if!(pInfo[playerid][Adminlevel] >= 1)

But first one is better I think.
Reply
#3

You mean this?

pawn Код:
if(pInfo[playerid][Adminlevel] >= 1)
This means greater tha level 1.

pawn Код:
if(pInfo[playerid][Adminlevel] <= 1)
This means if player is less than level 1.

pawn Код:
if(pInfo[playerid][Adminlevel] == 1)
This maybe.

> : Greater than.
<: Less than.
Reply
#4

https://sampwiki.blast.hk/wiki/Control_Structures#Operators
Reply
#5

No, I know the operators, I mean something like this:

if(pInfo[playerid][Adminlevel] !>= 1)

But I don't think you can have 3 Operators?

I'm trying to make it so it's that if the person using the command isn't admin return a message, or if they are greater than or equal to the level 1, proceed with the command. Hope this part helps
Reply
#6

Quote:
Originally Posted by Bingo
Посмотреть сообщение
You mean this?

pawn Код:
if(pInfo[playerid][Adminlevel] >= 1)
This means greater tha level 1.

pawn Код:
if(pInfo[playerid][Adminlevel] <= 1)
This means if player is less than level 1.

> : Greater than.
<: Less than.
There is difference between > & >= so as < & <= not being offensive but you need to learn more about it so you can answer people properly and don't give them wrong answers.

> - Greater than
< - Less than
>= Greater than & equal to.
<= Less than & equal to.


Quote:
Originally Posted by NoahF
Посмотреть сообщение
No, I know the operators, I mean something like this:

if(pInfo[playerid][Adminlevel] !>= 1)

But I don't think you can have 3 Operators?
You can't have 3 operator all together but you could do is

pawn Код:
//or = ||
if( pInfo[playerid][Adminlevel] >= 1 || pInfo[playerid][Adminlevel] != 1 )
                                ^                                   ^
                                |                                   |
                    //greater or equal than 1                   //is not 1
Reply
#7

Ah, that's what I was looking for, thank you!

EDIT:

Ok so i've added what you said.. and I am a level 2 admin ig and it still says I am not an admin.

Код:
CMD:acmds(playerid, params[])
{
	if( pInfo[playerid][Adminlevel] >= 1 || pInfo[playerid][Adminlevel] != 1 ) return SendClientMessage(playerid, COLOR_RED, "You are not an Admin.");
	{
		SendClientMessage(playerid, COLOR_BLUE, "Admin CMDS: /ban /kick /haunt /givemoney /v /armourme");
		SendClientMessage(playerid, COLOR_RED, "Admin CMDS: /clearchat /explode /godon /godoff /akill");
		SendClientMessage(playerid, COLOR_BLUE, "Admin CMDS: /healme /jail /unjail /healall /armourall");
	}
	return 1;
}
Reply
#8

pawn Код:
CMD:acmds(playerid, params[])
{
    if( pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, "You are not an Admin."); //less then 1

    SendClientMessage(playerid, COLOR_BLUE, "Admin CMDS: /ban /kick /haunt /givemoney /v /armourme");
    SendClientMessage(playerid, COLOR_RED, "Admin CMDS: /clearchat /explode /godon /godoff /akill");
    SendClientMessage(playerid, COLOR_BLUE, "Admin CMDS: /healme /jail /unjail /healall /armourall");
    return 1;
}
Reply
#9

You could do something simple like:

pawn Код:
CMD:acmds(playerid, params[])
{
    if( pInfo[playerid][Adminlevel] > 0 )
    {
        SendClientMessage(playerid, COLOR_BLUE, "Admin CMDS: /ban /kick /haunt /givemoney /v /armourme");
        SendClientMessage(playerid, COLOR_RED, "Admin CMDS: /clearchat /explode /godon /godoff /akill");
        SendClientMessage(playerid, COLOR_BLUE, "Admin CMDS: /healme /jail /unjail /healall /armourall");
    }
    else SendClientMessage(playerid, COLOR_RED, "You are not an Admin.");
    return 1;
}
Reply
#10

Xabi's solution fixed it. Thanks all of you for the help!!! Much appreciated
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)