SA-MP Forums Archive
IsPilotVehicle is never called - 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: IsPilotVehicle is never called (/showthread.php?tid=605054)



IsPilotVehicle is never called - NeXoR - 13.04.2016

The function is never called for some reason
I tried debugging using printf the vehicle id but nothing pops on console

stock and usage:

Stock
PHP код:
stock IsPilotVehicle(vehicleid)
{
    
printf("Test: %s."vehicleid);
    for(new 
i=0i<2i++)
    {
        if(
vehicleid == JobInfo[JOB_PILOT][jCars][i]) return 1;
    }
    return 
0;

OnPlayerEnterVehicle

PHP код:
else if(IsPilotVehicle(vehicleid))
        {
            
printf("Test = %i."vehicleid);
            if(
PlayerInfo[playerid][pJob] != JOB_PILOT && PlayerInfo[playerid][pVIPJob] != JOB_PILOT)
            {
                
printf("TEST = %i.",vehicleid);
                  new 
Float:pos[3];
                
GetPlayerPos(playeridpos[0], pos[1], pos[2]);
                
SetPlayerPos(playeridpos[0], pos[1], pos[2]);
                
SendClientMessage(playeridCOLOR_ORANGE"You cannot start the engine as it belongs to the Los Santos Airline Company.");
            }
        } 



Re: IsPilotVehicle is never called - BiosMarcel - 13.04.2016

Is something else inside of your "if - else - else if " construct called? Just add print("Test"); or smth to check it


Re: IsPilotVehicle is never called - NeXoR - 13.04.2016

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Is something else inside of your "if - else - else if " construct called? Just add print("Test"); or smth to check it
Print shows nothing
Like the else is never called


Re: IsPilotVehicle is never called - NaS - 13.04.2016

First off you use %s for an integer, make it a %d or %i.

Also, what does the if before "else if(IsPilotVehicle(vehicleid))" check for?


Re: IsPilotVehicle is never called - NeXoR - 13.04.2016

Quote:
Originally Posted by NaS
Посмотреть сообщение
First off you use %s for an integer, make it a %d or %i.

Also, what does the if before "else if(IsPilotVehicle(vehicleid))" check for?
The rest of the public OnPlayerEnterVehicle
If hes not a cop cant enter LSPD cars, if hes not a GOV cant enter GOV cars etc etc


Re: IsPilotVehicle is never called - NeXoR - 14.04.2016

Anyone ?


Re: IsPilotVehicle is never called - NaS - 14.04.2016

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
The rest of the public OnPlayerEnterVehicle
If hes not a cop cant enter LSPD cars, if hes not a GOV cant enter GOV cars etc etc
Does that work correctly (the ones before the pilot)?

It seems that the whole else if doesn't get called, so the if structure just before your IsPilotVehicle could be wrong.

And did you change the %s to %d in the first printf inside your IsPilotVehicle function?


Re: IsPilotVehicle is never called - NeXoR - 14.04.2016

Quote:
Originally Posted by NaS
Посмотреть сообщение
Does that work correctly (the ones before the pilot)?

It seems that the whole else if doesn't get called, so the if structure just before your IsPilotVehicle could be wrong.

And did you change the %s to %d in the first printf inside your IsPilotVehicle function?
The else ifs before the IsPilotVehicle works perfect
I tried changing the else if to if, maybe it would work
and yeah I changed s to d