Pawn Operator "!" Bug
#1

pawn Код:
// I use this in a timer
new tmpcar = GetPlayerVehicleID(playerid);
if(!IsAShamal(playerid)) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal.");
Ok , this works , but if i use 2 ! operators , the function don't works

pawn Код:
// I use this in a timer
new tmpcar = GetPlayerVehicleID(playerid);
if(!IsAShamal(tmpcar) || !IsAnAndromada(tmpcar)) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
Reply
#2

That isn't a bug. Replace || by &&.
Reply
#3

pawn Код:
if((!IsAShamal(tmpcar)) || (!IsAnAndromada(tmpcar))) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
This should work aswell.
Reply
#4

That does the exact same thing..

Use the code 0rb is suggesting.
Reply
#5

lol if && then the player MUST BE in a shamal and andromeda at a time.....
BTW
where you have
GetPlayerVehicleID(playerid);
use
GetVehicleModel(GetPlayerVehicleID(playerid));
so leave the ||

@
Quote:
Originally Posted by 0rb
That isn't a bug. Replace || by &&.
So you think the player can be in a shamal and a andromada at 1 time?

@
Quote:
Originally Posted by Martins342
pawn Код:
if((!IsAShamal(tmpcar)) || (!IsAnAndromada(tmpcar))) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
This should work aswell.
why more ( ) ?.. nothing changed.
Reply
#6

Quote:
Originally Posted by gamer_Z
lol if && then the player MUST BE in a shamal and andromeda at a time.....
BTW
where you have
GetPlayerVehicleID(playerid);
use
GetVehicleModel(GetPlayerVehicleID(playerid));
No, I thought that at first but then I thought about it more.

The goal is to only continue if they are in a shamal or a andromada.

Idk how to explain it but it makes sence when you think about it...

You could do:

pawn Код:
// I use this in a timer
new tmpcar = GetPlayerVehicleID(playerid);
if(!IsAShamal(tmpcar) && !IsAnAndromada(tmpcar)) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");

or you could do:

pawn Код:
// I use this in a timer
new tmpcar = GetPlayerVehicleID(playerid);
if(IsAShamal(tmpcar) || IsAnAndromada(tmpcar))
{
  // Code here
} else return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");


Both should work in theory
Reply
#7

Notice how he says
"You are not in a shamal or in a Andromada."
That meaning you can't be in the Shamel OR Andromeda. Thus, needing a && statement.
Reply
#8

Quote:
Originally Posted by Lavamike
Quote:
Originally Posted by gamer_Z
lol if && then the player MUST BE in a shamal and andromeda at a time.....
BTW
where you have
GetPlayerVehicleID(playerid);
use
GetVehicleModel(GetPlayerVehicleID(playerid));
No, I thought that at first but then I thought about it more.

The goal is to only continue if they are in a shamal or a andromada.

Idk how to explain it but it makes sence when you think about it...

You could do:

pawn Код:
// I use this in a timer
new tmpcar = GetPlayerVehicleID(playerid);
if(!IsAShamal(tmpcar) && !IsAnAndromada(tmpcar)) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");

or you could do:

pawn Код:
// I use this in a timer
new tmpcar = GetPlayerVehicleID(playerid);
if(IsAShamal(tmpcar) || IsAnAndromada(tmpcar))
{
  // Code here
} else return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");


Both should work in theory
if u just use GetPlayerVehicleID(playerid); then u need
to define all andromadas and shamals frm the gamemod to somewhere...
so it knows what (server)vehicleid's those have..
ex a shamal can be placed somewhere on the map...
and it can have id 50 and another shamal can have id 421
and the MODELID of this 2 shamals will ALWAYS be 519..

btw with the && and ||

&& means that this also MUST be "done"
and || stands for "OR"..

Example:
pawn Код:
if(!dini_Exists(udb_encode(PlayerName(playerid))) && LoggedIn[playerid] == 1)// if playerfile doesn't exist AND player is logged in.
    {
        dini_Create(udb_encode(PlayerName(playerid)));
        dini_IntSet(udb_encode(PlayerName(playerid)), "score", GetPlayerScore(playerid));
        dini_IntSet(udb_encode(PlayerName(playerid)), "skin", GetPlayerSkin(playerid));
        LoggedIn[playerid] = 0;
        SetPlayerScore(playerid,0);
        return 1;
    }
    if(!dini_Exists(udb_encode(PlayerName(playerid))) || LoggedIn[playerid] == 1)// if playerfile doesn't exist OR player is logged in, this could probably crash.
    {
        dini_Create(udb_encode(PlayerName(playerid)));
        dini_IntSet(udb_encode(PlayerName(playerid)), "score", GetPlayerScore(playerid));
        dini_IntSet(udb_encode(PlayerName(playerid)), "skin", GetPlayerSkin(playerid));
        LoggedIn[playerid] = 0;
        SetPlayerScore(playerid,0);
        return 1;
    }
So your "TOTAL" code will look like

pawn Код:
IsAShamal
{
    switch(model)
    {
        case 519:return 1;
    }
    return 0;
}
IsAndromada
{
    switch(model)
    {
        case 592:return 1;
    }
    return 0;
}
new tmpcar = GetPlayerModel(GetPlayerVehicleID(playerid));
if(!IsAShamal(tmpcar) || !IsAnAndromada(tmpcar)) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
Or u can make the code a litle more tinny:
pawn Код:
IsWantedPlane
{
    switch(model)
    {
        case 519:return 1;
        case 592:return 1;
    }
    return 0;
}
new tmpcar = GetPlayerModel(GetPlayerVehicleID(playerid));
if(!IsWantedPlane(tmpcar)) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
Reply
#9

Quote:
Originally Posted by gamer_Z
lol if && then the player MUST BE in a shamal and andromeda at a time.....
BTW
where you have
GetPlayerVehicleID(playerid);
use
GetVehicleModel(GetPlayerVehicleID(playerid));
so leave the ||

@
Quote:
Originally Posted by 0rb
That isn't a bug. Replace || by &&.
So you think the player can be in a shamal and a andromada at 1 time?

@
Quote:
Originally Posted by Martins342
pawn Код:
if((!IsAShamal(tmpcar)) || (!IsAnAndromada(tmpcar))) return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
This should work aswell.
why more ( ) ?.. nothing changed.
I guess this what IsAShamal supposes to do.
Reply
#10

this should be the fix..
pawn Код:
IsWantedPlane{
    switch(model){
        case 519:return 1;//shamal
        case 592:return 1;//andromada
    }
    return 0;
}
new tmpcar = GetPlayerModel(GetPlayerVehicleID(playerid));
if(IsWantedPlane(tmpcar)){//yeah lavamike has als a good solution in combination with mine so it's the ultimate solution xD
  // Code here
} else return SendClientMessage(playerid,COLOR_WHITE,"You are not in a shamal or in a Andromada.");
so you use 0 times ! and it is tiny
so there is no need to use || and && and thousands of !iscar1 !iscar2 !iscar3....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)