SA-MP Forums Archive
OnPlayerEnterCheckpoint doesn't work properly. - 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: OnPlayerEnterCheckpoint doesn't work properly. (/showthread.php?tid=658891)



OnPlayerEnterCheckpoint doesn't work properly. - AzaMx - 15.09.2018

Whenever I enter the last checkpoint [23], it doesn't get called or working. It doesn't return anything.

PHP код:
    if(GetPVarInt(playerid"LicenseCP") != 0)
    {
        new 
cnt GetPVarInt(playerid"LicenseCP");
        if(
DriveCP[cnt][3] == 23)
        {
            new 
Float:Health;
            
GetVehicleHealth(GetPlayerVehicleID(playerid), Health);
            if(
Health 700)
            {
                
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
                
SetPVarInt(playerid"LicenseCP",0);
                
DisablePlayerCheckpoint(playerid);
                
PlayerInfo[playerid][driverlic]=1;
                
SendClientInfo(playerid"Congratulations, you passed the driving test.");
            }
            else if(
Health 699)
            {
                
DisablePlayerCheckpoint(playerid);
                
SetPVarInt(playerid"LicenseCP",0);
                
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
                
SendClientInfo(playerid"You have damaged your vehicle, therefore you failed the driving test.");
            }
        }
        
cnt++;
        
SetPVarInt(playerid"LicenseCP"cnt);
        
KillTimer(CPTimer[playerid]);
        
DisablePlayerCheckpoint(playerid);
        
CPTimer[playerid] = SetTimerEx("SetCP"200true"dffff"playeridDriveCP[cnt][0],DriveCP[cnt][1],DriveCP[cnt][2], 5.0);
        return 
1;
    } 



Re: OnPlayerEnterCheckpoint doesn't work properly. - UFF - 15.09.2018

I suggest you to use race checkpoint.


Re: OnPlayerEnterCheckpoint doesn't work properly. - v1k1nG - 15.09.2018

Print something for debugging. If it doesn't print anything that part of code is not getting called at all


Re: OnPlayerEnterCheckpoint doesn't work properly. - UFF - 15.09.2018

Quote:
Originally Posted by v1k1nG
Посмотреть сообщение
Print something for debugging. If it doesn't print anything that part of code is not getting called at all
OnPlayerEnterCheckpoint works only with checkpointid. So, that his whole code will not be called(even debug will not show anything) since he is using pvars. Hence, he cam move to OnPlayerEnterRaceCheckpoint which works with only playerid.


Re: OnPlayerEnterCheckpoint doesn't work properly. - GTLS - 15.09.2018

Quote:
Originally Posted by UFF
Посмотреть сообщение
I suggest you to use race checkpoint.
How the hell does it change anything? Except for shape yes.

whats this?
Код:
 if(DriveCP[cnt][3] == 23)
Whats the cnt variable for? For the count of steps(or checkpoints)? cuz, that would be 23 if its 23rd checkpoint.


Re: OnPlayerEnterCheckpoint doesn't work properly. - v1k1nG - 15.09.2018

Quote:
Originally Posted by UFF
Посмотреть сообщение
OnPlayerEnterCheckpoint works only with checkpointid. So, that his whole code will not be called(even debug will not show anything) since he is using pvars. Hence, he cam move to OnPlayerEnterRaceCheckpoint which works with only playerid.
Nah I think that if I write under OnPlayerEnterCheckpoint anything without checking checkpointid, it will get called anytime I enter any CP, because I didn't check its ID.


Re: OnPlayerEnterCheckpoint doesn't work properly. - Undef1ned - 15.09.2018

Test.

PHP код:
if(GetPVarInt(playerid"LicenseCP") != 0
    { 
        new 
cnt GetPVarInt(playerid"LicenseCP"); 
        if(
GetPVarInt(playerid"LicenseCP") <= 23)
        { 
            new 
Float:Health
            
GetVehicleHealth(GetPlayerVehicleID(playerid), Health); 
            if(
Health 700
            { 
                
SetVehicleToRespawn(GetPlayerVehicleID(playerid)); 
                
SetPVarInt(playerid"LicenseCP",0); 
                
DisablePlayerCheckpoint(playerid); 
                
PlayerInfo[playerid][driverlic]=1
                
SendClientInfo(playerid"Congratulations, you passed the driving test."); 
            } 
            else if(
Health 699
            { 
                
DisablePlayerCheckpoint(playerid); 
                
SetPVarInt(playerid"LicenseCP",0); 
                
SetVehicleToRespawn(GetPlayerVehicleID(playerid)); 
                
SendClientInfo(playerid"You have damaged your vehicle, therefore you failed the driving test."); 
            } 
        } 
        
cnt++; 
        
SetPVarInt(playerid"LicenseCP"cnt); 
        
KillTimer(CPTimer[playerid]); 
        
DisablePlayerCheckpoint(playerid); 
        
CPTimer[playerid] = SetTimerEx("SetCP"200true"dffff"playeridDriveCP[cnt][0],DriveCP[cnt][1],DriveCP[cnt][2], 5.0); 
        return 
1
    } 



Re: OnPlayerEnterCheckpoint doesn't work properly. - AzaMx - 15.09.2018

Quote:
Originally Posted by GTLS
Посмотреть сообщение
How the hell does it change anything? Except for shape yes.

whats this?
Код:
 if(DriveCP[cnt][3] == 23)
Whats the cnt variable for? For the count of steps(or checkpoints)? cuz, that would be 23 if its 23rd checkpoint.
cnt stands for this
PHP код:
new cnt GetPVarInt(playerid"LicenseCP"); 
Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
PHP код:
if(GetPVarInt(playerid"LicenseCP") != 0
    { 
        new 
cnt GetPVarInt(playerid"LicenseCP"); 
        if(
GetPVarInt(playerid"LicenseCP") <= 23)
        { 
            new 
Float:Health
            
GetVehicleHealth(GetPlayerVehicleID(playerid), Health); 
            if(
Health 700
            { 
                
SetVehicleToRespawn(GetPlayerVehicleID(playerid)); 
                
SetPVarInt(playerid"LicenseCP",0); 
                
DisablePlayerCheckpoint(playerid); 
                
PlayerInfo[playerid][driverlic]=1
                
SendClientInfo(playerid"Congratulations, you passed the driving test."); 
            } 
            else if(
Health 699
            { 
                
DisablePlayerCheckpoint(playerid); 
                
SetPVarInt(playerid"LicenseCP",0); 
                
SetVehicleToRespawn(GetPlayerVehicleID(playerid)); 
                
SendClientInfo(playerid"You have damaged your vehicle, therefore you failed the driving test."); 
            } 
        } 
        
cnt++; 
        
SetPVarInt(playerid"LicenseCP"cnt); 
        
KillTimer(CPTimer[playerid]); 
        
DisablePlayerCheckpoint(playerid); 
        
CPTimer[playerid] = SetTimerEx("SetCP"200true"dffff"playeridDriveCP[cnt][0],DriveCP[cnt][1],DriveCP[cnt][2], 5.0); 
        return 
1
    } 
PHP код:
if(GetPVarInt(playerid"LicenseCP") <= 23
Then how about the CP lol


Re: OnPlayerEnterCheckpoint doesn't work properly. - Undef1ned - 15.09.2018

Quote:
Originally Posted by AzaMx
Посмотреть сообщение
cnt stands for this
PHP код:
new cnt GetPVarInt(playerid"LicenseCP"); 

PHP код:
if(GetPVarInt(playerid"LicenseCP") <= 23
Then how about the CP lol
It worked or what?


Re: OnPlayerEnterCheckpoint doesn't work properly. - AzaMx - 16.09.2018

of course not.