SA-MP Forums Archive
Pawn Operator "!" Bug - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pawn Operator "!" Bug (/showthread.php?tid=84906)



Pawn Operator "!" Bug - UsaBoy91 - 03.07.2009

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.");



Re: Pawn Operator "!" Bug - yom - 03.07.2009

That isn't a bug. Replace || by &&.


Re: Pawn Operator "!" Bug - Martins342 - 04.07.2009

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.


Re: Pawn Operator "!" Bug - Grim_ - 04.07.2009

That does the exact same thing..

Use the code 0rb is suggesting.


Re: Pawn Operator "!" Bug - Gamer_Z - 04.07.2009

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.


Re: Pawn Operator "!" Bug - lavamike - 04.07.2009

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


Re: Pawn Operator "!" Bug - Grim_ - 04.07.2009

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.



Re: Pawn Operator "!" Bug - Gamer_Z - 04.07.2009

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.");



Re: Pawn Operator "!" Bug - MenaceX^ - 04.07.2009

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.


Re: Pawn Operator "!" Bug - Gamer_Z - 04.07.2009

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....