Help Race CP
#1

Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
	if(Para[playerid] == 1)
	{
	    new Vehicle;
	    DisablePlayerRaceCheckpoint(playerid);
	    PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
	    Quad[playerid] = 1;
	    SetPlayerPos(playerid, -270.7894,-1942.0770,28.3374);
	    SetPlayerFacingAngle(playerid, 6.0637);
		Vehicle = CreateVehicle(471, -270.7894,-1942.0770,28.3374, 6.0637, -1, -1, -1);
		PutPlayerInVehicle(playerid, Vehicle, 0);
		SetPlayerRaceCheckpoint(playerid, 0, -324.8318,-1917.5735,12.9568, -424.3269,-1915.1814,6.2759, 10);
	}

	if(Quad[playerid] == 1)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -324.8318,-1917.5735,12.9568, -424.3269,-1915.1814,6.2759, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 2;
	}
	
	if(Quad[playerid] == 2)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -424.3269,-1915.1814,6.2759, -448.0903,-1985.1914,29.7391, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 3;
	}
	
	if(Quad[playerid] == 3)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -424.3269,-1915.1814,6.2759, -448.0903,-1985.1914,29.7391, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 4;
	}
	
	if(Quad[playerid] == 4)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -448.0903,-1985.1914,29.7391, -493.8112,-2025.1213,49.5716, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 5;
	}
	
	if(Quad[playerid] == 5)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -493.8112,-2025.1213,49.5716, -639.2380,-2026.9741,30.6198, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 6;
	}
	
	if(Quad[playerid] == 6)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -639.2380,-2026.9741,30.6198, -684.1072,-2102.7007,25.7731, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 7;
	}
	
	if(Quad[playerid] == 7)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -684.1072,-2102.7007,25.7731, -763.7418,-2122.3665,25.0361, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 8;
	}
	
	if(Quad[playerid] == 8)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -763.7418,-2122.3665,25.0361, -803.8206,-2163.8210,22.2477, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 9;
	}
	
	if(Quad[playerid] == 9)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -803.8206,-2163.8210,22.2477, -876.7202,-2183.1133,27.2250, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 10;
	}
	
	if(Quad[playerid] == 10)
	{
	    DisablePlayerRaceCheckpoint(playerid);
		SetPlayerRaceCheckpoint(playerid, 0, -876.7202,-2183.1133,27.2250, -958.5380,-2232.8008,42.1912, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 11;
	}
	
	if(Quad[playerid] == 11)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -958.5380,-2232.8008,42.1912, -946.5872,-2343.9014,59.9226, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 12;
	}
	
	if(Quad[playerid] == 12)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -946.5872,-2343.9014,59.9226, -993.3751,-2367.9868,65.1090, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 13;
	}
	
	if(Quad[playerid] == 13)
	{
        DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -993.3751,-2367.9868,65.1090, -1068.9324,-2378.8877,46.6570, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 14;
	}
	
	if(Quad[playerid] == 14)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1068.9324,-2378.8877,46.6570, -1179.2466,-2359.8438,19.8485, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 15;
	}
	
	if(Quad[playerid] == 15)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1179.2466,-2359.8438,19.8485, -1266.0793,-2250.4758,22.1066, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 16;
	}
	
	if(Quad[playerid] == 16)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1266.0793,-2250.4758,22.1066, -1361.7170,-2182.1726,22.5443, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 17;
	}
	
	if(Quad[playerid] == 17)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1361.7170,-2182.1726,22.5443, -1555.3273,-2151.5896,9.7962, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 18;
	}
	
	if(Quad[playerid] == 18)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1555.3273,-2151.5896,9.7962, -1668.9247,-2197.0623,34.2701, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 19;
	}
	
	if(Quad[playerid] == 19)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1668.9247,-2197.0623,34.2701, -1694.2645,-2286.9070,42.3592, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 20;
	}
	
	if(Quad[playerid] == 20)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1694.2645,-2286.9070,42.3592, -1793.3618,-2310.8914,43.0129, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 21;
	}
	
	if(Quad[playerid] == 21)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0, -1793.3618,-2310.8914,43.0129, -1896.9579,-2409.9802,32.0881, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		Quad[playerid] = 22;
	}
	
	if(Quad[playerid] == 22)
	{
	    DisablePlayerRaceCheckpoint(playerid);
	    SetPlayerRaceCheckpoint(playerid, 1, -1967.8353,-2450.9392,30.6250, 0.0,0.0,0.0, 10);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
	}
	return 1;
}
This is not show me the quad race cp
What the problem ??
Reply
#2

The problem is that you don't use a switch or in the worst case scenario else-if and the one part is executed right after another.

That is what happens:
Quad to 1
if (Quad == 1) Quad to 2
if (Quad == 2) Quad to 3
and so on.. until it reaches 22 and all that in mere seconds.

I'd strongly advise you to check for a racing system than creating manually and adding to the script.

PS: Plus you don't need to disable race checkpoint to show the next one just show it directly; it does the exact same thing.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The problem is that you don't use a switch or in the worst case scenario else-if and the one part is executed right after another.

That is what happens:
Quad to 1
if (Quad == 1) Quad to 2
if (Quad == 2) Quad to 3
and so on.. until it reaches 22 and all that in mere seconds.

I'd strongly advise you to check for a racing system than creating manually and adding to the script.

PS: Plus you don't need to disable race checkpoint to show the next one just show it directly; it does the exact same thing.
This is not show the CP you can fix this pls ??
Reply
#4

Let's recreate how this callback is executed upon going through the first checkpoint:
Код:
> First checkpoint reached
> Quad[playerid] = 1
> if-statement: is Quad[playerid] == 1? True.
> Execute body
> Quad[playerid] = 2
> if-statement: is Quad[playerid] == 2? True.
> Execute body
> Quad[playerid] = 3
> if-statement: is Quad[playerid] == 3? True.
> Execute body
> ...
And it continues to do so till the last if statement for Quad[playerid] == n is reached.

You can fix this logical error by replacing these if-statements with a switch-statement:
PHP код:
switch(Quad[playerid]) {
    case 
1: {
        
// Quad[playerid] == 1
    
}
    case 
2: {
        
// Quad[playerid] == 2
    
}
    case 
3: {
        
// Quad[playerid] == 3
    
}
    case 
4: {
        
// Quad[playerid] == 4
    
}
} 
EDIT: and I should start refreshing my pages before submitting my replies.
Reply
#5

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Let's recreate how this callback is executed upon going through the first checkpoint:
Код:
> First checkpoint reached
> Quad[playerid] = 1
> if-statement: is Quad[playerid] == 1? True.
> Execute body
> Quad[playerid] = 2
> if-statement: is Quad[playerid] == 2? True.
> Execute body
> Quad[playerid] = 3
> if-statement: is Quad[playerid] == 3? True.
> Execute body
> ...
And it continues to do so till the last if statement for Quad[playerid] == n is reached.

You can fix this logical error by replacing these if-statements with a switch-statement:
PHP код:
switch(Quad[playerid]) {
    case 
1: {
        
// Quad[playerid] == 1
    
}
    case 
2: {
        
// Quad[playerid] == 2
    
}
    case 
3: {
        
// Quad[playerid] == 3
    
}
    case 
4: {
        
// Quad[playerid] == 4
    
}
} 
EDIT: and I should start refreshing my pages before submitting my replies.
Now the first CP teleport me to start point
Код:
	switch(Quad[playerid])
	{
	    case 1:
		{
	 		DisablePlayerRaceCheckpoint(playerid);
			SetPlayerRaceCheckpoint(playerid, 0, -324.8318,-1917.5735,12.9568, -424.3269,-1915.1814,6.2759, 10);
			PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
			Quad[playerid] = 2;
	    }
Reply
#6

Isn't that what this does?:
PHP код:
    if(Para[playerid] == 1)
    {
        new 
Vehicle;
        
DisablePlayerRaceCheckpoint(playerid);
        
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
        
Quad[playerid] = 1;
        
SetPlayerPos(playerid, -270.7894,-1942.0770,28.3374);
        
SetPlayerFacingAngle(playerid, 6.0637);
        
Vehicle = CreateVehicle(471, -270.7894,-1942.0770,28.3374, 6.0637, -1, -1, -1);
        
PutPlayerInVehicle(playerid, Vehicle, 0);
        
SetPlayerRaceCheckpoint(playerid, 0, -324.8318,-1917.5735,12.9568, -424.3269,-1915.1814,6.2759, 10);
    } 
Seems like the only part in your code that teleports the player.
Reply
#7

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Isn't that what this does?:
PHP код:
    if(Para[playerid] == 1)
    {
        new 
Vehicle;
        
DisablePlayerRaceCheckpoint(playerid);
        
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
        
Quad[playerid] = 1;
        
SetPlayerPos(playerid, -270.7894,-1942.0770,28.3374);
        
SetPlayerFacingAngle(playerid, 6.0637);
        
Vehicle = CreateVehicle(471, -270.7894,-1942.0770,28.3374, 6.0637, -1, -1, -1);
        
PutPlayerInVehicle(playerid, Vehicle, 0);
        
SetPlayerRaceCheckpoint(playerid, 0, -324.8318,-1917.5735,12.9568, -424.3269,-1915.1814,6.2759, 10);
    } 
Seems like the only part in your code that teleports the player.
What the problem I don't understand you, I not see problem

EDIT: this code teleport player to start point quad race and create quad and create race CP
Reply
#8

Since the if-statement checking Para[playerid] is also in the callback, I believe that it is a checkpoint too. The first checkpoint to be exact. Of course it will teleport the player to the starting location; you scripted it to do that.
Reply
#9

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Since the if-statement checking Para[playerid] is also in the callback, I believe that it is a checkpoint too. The first checkpoint to be exact. Of course it will teleport the player to the starting location; you scripted it to do that.
Can you show to me this in the code ?
Reply
#10

You are really confusing me too now. What is the problem? You've scripted it so that the first checkpoint teleports the player:

PHP код:
        Quad[playerid] = 1; 
        
SetPlayerPos(playerid, -270.7894,-1942.0770,28.3374); 
        
SetPlayerFacingAngle(playerid, 6.0637); 
It teleports the player (sets their position) and then it creates the first actual racing checkpoint. Unless you didn't intend to do this, it's correct behaviour.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)