A weird bug?!
#1

Hello everybody,

I've got a bug since one/two months but I can't fix it because he's so weird. I've searched and asked for help a lot of times but no one cares or maybe no one knows the solution of this one.

The problem that when I write if and after that I write else if in some callbacks (onplayerdeath, onplayerstatechange, onplayerentervehicle and maybe other callbacks) It doesn't work... The if condition work but the others (else if) doesn't work. Can I have a possible solution of this please ? Thanks.
Reply
#2

You're probably messing it up, show us how you're doing it perhaps.
Reply
#3

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:Pos[3];
    if(!ispassenger)
    {
         if(IsPoliceVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas membre de la police!");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
         }
         if(IsCamionneurVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas camionneur ou vous n'avez pas les compйtences nйcessaires ou vous n'кtes pas en service.");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
         }
         else if(IsAmbulancierVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas ambulancier.");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             printf("Ambulance");
         }
    }
    return 1;
}
The two else if doesn't work.
Reply
#4

Have you tried changing the "else if" to "if"?
Reply
#5

Quote:
Originally Posted by streetpeace
Посмотреть сообщение
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:Pos[3];
    if(!ispassenger)
    {
         if(IsPoliceVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas membre de la police!");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
         }
         if(IsCamionneurVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas camionneur ou vous n'avez pas les compйtences nйcessaires ou vous n'кtes pas en service.");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
         }
         else if(IsAmbulancierVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas ambulancier.");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             printf("Ambulance");
         }
    }
    return 1;
}
The two else if doesn't work.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Float:Pos[3];
    if(!ispassenger)
    {
         if(IsPoliceVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas membre de la police!");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
         }
         else if(IsCamionneurVeh(vehicleid)) // This needs to be like this
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas camionneur ou vous n'avez pas les compйtences nйcessaires ou vous n'кtes pas en service.");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
         }
         else if(IsAmbulancierVeh(vehicleid))
         {
             SendClientMessage(playerid, -1, "Vous n'кtes pas ambulancier.");
             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
             printf("Ambulance");
         }
    }
    return 1;
}
Also you maybe have a problem in your functions. Maybe they return 0 which makes the script ignore the statement.

Show us the functions. All 3 of them.
Reply
#6

pawn Код:
stock IsCamionneurVeh(vehicleid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(vehicleid == CamionneurVeh[i]) return true;
    }
    return true;
}
stock IsAmbulancierVeh(vehicleid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(vehicleid == Ambulances[i]) return true;
    }
    return true;
}
stock IsPoliceVeh(vehicleid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(vehicleid == LSPDVoiture[i]) return true;
    }
    return true;
}
Here is the code and your solution doesn't work (about else if)
Reply
#7

You don't return false at all so the result will always be true. Therefore, the first one is always true, and the other one's aren't called because of it.
Reply
#8

I've already searched a lot of times for a possible solution for this bug but I can't find something that can fix this problem. I have the same problems with some others callbacks (onplayerdeath, onplayerstatechange..) please help me.
Reply
#9

no one can help ?
Reply
#10

pawn Код:
stock IsCamionneurVeh(vehicleid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(vehicleid == CamionneurVeh[i]) return true;
    }
    return false;
}
stock IsAmbulancierVeh(vehicleid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(vehicleid == Ambulances[i]) return true;
    }
    return false;
}
stock IsPoliceVeh(vehicleid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(vehicleid == LSPDVoiture[i]) return true;
    }
    return false;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)