PutPlayerInVehicle BUG
#1

Holla, I am creating a Derby filterscript, and I am actually freaking out here.
When the Admin starts the derby you have 15 seconds to enter it, and then you are teleported to your car.
But somehow, it DOESNT teleport me to my car.

Codes:
Vehicle creation and definition
PHP код:
    DerbyVehicle[0] = CreateVehicle(451, -4346.9165, -874.46124.934990.0000155, -1100);
    
DerbyVehicle[1] = CreateVehicle(451, -4346.9170, -906.17244.934990.0000155, -1100);
    
DerbyVehicle[2] = CreateVehicle(451, -4346.9814, -908.87874.934990.0000155, -1100);
    
DerbyVehicle[3] = CreateVehicle(451, -4347.0225, -911.58134.934990.0000155, -1100);
    
DerbyVehicle[4] = CreateVehicle(451, -4347.1064, -914.35914.934990.0000155, -1100);
    
DerbyVehicle[5] = CreateVehicle(451, -4347.1304, -917.15334.934990.0000155, -1100);
    
DerbyVehicle[6] = CreateVehicle(451, -4347.1743, -920.14834.934990.0000155, -1100);
    
DerbyVehicle[7] = CreateVehicle(451, -4347.1587, -923.18504.934990.0000155, -1100);
    
DerbyVehicle[8] = CreateVehicle(451, -4347.1777, -926.16494.934990.0000155, -1100);
    
DerbyVehicle[9] = CreateVehicle(451, -4347.2012, -929.14494.934990.0000155, -1100);
    
DerbyVehicle[10] = CreateVehicle(451, -4347.2671, -932.28014.934990.0000155, -1100);
    
DerbyVehicle[11] = CreateVehicle(451, -4347.2109, -935.24514.934990.0000155, -1100);
    
DerbyVehicle[12] = CreateVehicle(451, -4347.2285, -938.10914.934990.0000155, -1100);
    
DerbyVehicle[13] = CreateVehicle(451, -4347.1670, -940.96604.934990.0000155, -1100);
    
DerbyVehicle[14] = CreateVehicle(451, -4347.1865, -943.77444.934990.0000155, -1100);
    
DerbyVehicle[15] = CreateVehicle(451, -4347.1860, -946.42424.934990.0000155, -1100);
    
DerbyVehicle[16] = CreateVehicle(451, -4347.1475, -949.24724.934990.0000155, -1100);
    
DerbyVehicle[17] = CreateVehicle(451, -4347.2119, -964.88764.934990.0000155, -1100);
    
DerbyVehicle[18] = CreateVehicle(451, -4347.1606, -980.29254.934990.0000155, -1100);
    
DerbyVehicle[19] = CreateVehicle(451, -4347.1401, -890.88384.934990.0000155, -1100); 
CMDerby (start the derby)
PHP код:
CMD:derby(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1".айрк агойп йа орйач");
    new 
maxp;
    if(
sscanf(params"i"maxp)) return SendClientMessage(playerid, -1"/Derby [Max Players] :щйоещ");
    if(
maxp || maxp 20) return SendClientMessage(playerid, -1"осфш ощъъфйн бйп 2 м20 йа гбт");
    
DerbyMaxP maxp;
    
Derby 1;
    
SendClientMessageToAll(-1"/Join :фтймеъ дгшбй дзмд - тм оръ мдцишу дчщ");
    
DerbyTimer[0] = SetTimer("DerbyGame"150000);
    return 
1;

DerbyGame public (Where it teleports everyone to their cars)
PHP код:
forward DerbyGame();
public 
DerbyGame()
{
    if(
JoinedDerby 2)
    {
        foreach(new 
Player)
        {
            if(
DerbyKicked[i]) DerbyKicked[i] = 0;
            if(
DerbyPlayer[i]) DerbyPlayer[i] = 0;
        }
        
JoinedDerby 0;
        
DerbyMaxP 0;
        
SendClientMessageToAll(-1".йа жереъ фтн дбад ълрсе, дгшбй беим чцъ ойгй ощъъфйн");
        
Derby 0;
        for(new 
timer 0timer 3timer++) KillTimer(DerbyTimer[timer]);
    }
    for(new 
veh 0veh 20veh++) SetVehicleToRespawn(DerbyVehicle[veh]);
    foreach(new 
Player)
    {
        if(
DerbyPlayer[i])
        {
            for(new 
020j++)
            {
                if(
IsVehicleOccupied(DerbyVehicle[j])) continue;
                 
PutPlayerInVehicle(iDerbyVehicle[j], 0); // This doesn't work
                
TogglePlayerControllable(i0);
                
SendClientMessage(i, -1".дщъвшъ мфтймеъ дгшбй йа лелб, 10 щрйеъ ъщъзшш оддчфад");
                break;
            }
        }
    }
    
Derby 2;
    
DerbyTimer[1] = SetTimer("StartDerby"100000);
    return 
1;

IsVehicleOccupied
PHP код:
stock IsVehicleOccupied(vehicleid)
{
    foreach(new 
Player)
    {
        if(
IsPlayerConnected(i))
        {
            if(
GetPlayerVehicleID(i) == vehicleid && GetPlayerVehicleSeat(i) == 0) return true;
        }
    }
    return 
false;

Reply
#2

Can you replace your code with this one:

Код:
for(new j = 0; j < 20; j++) 
            { 
                if(!IsVehicleOccupied(DerbyVehicle[j]))
                {
                    PutPlayerInVehicle(i, DerbyVehicle[j], 0); 
                    TogglePlayerControllable(i, 0); 
                    SendClientMessage(i, -1, ".дщъвшъ мфтймеъ дгшбй йа лелб, 10 щрйеъ ъщъзшш оддчфад"); 
                    break;
                }
            }
If it doesn't work try print out the values of DerbyVehicle[j] and the other variable you use to try and find if you are lacking required information.
Reply
#3

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
Can you replace your code with this one:

Код:
for(new j = 0; j < 20; j++) 
            { 
                if(!IsVehicleOccupied(DerbyVehicle[j]))
                {
                    PutPlayerInVehicle(i, DerbyVehicle[j], 0); 
                    TogglePlayerControllable(i, 0); 
                    SendClientMessage(i, -1, ".дщъвшъ мфтймеъ дгшбй йа лелб, 10 щрйеъ ъщъзшш оддчфад"); 
                    break;
                }
            }
If it doesn't work try print out the values of DerbyVehicle[j] and the other variable you use to try and find if you are lacking required information.
At first it was your code, and then I edited it to the current version (with the continue;)
I tried debugging it in every possible way, nothing popped up.
Reply
#4

When is this DerbyPlayer[i] changed to a value higher than 0? Also, do you get frozen or nothing under the code there gets executed? No SCM, no PutPlayerInVehicle, no TogglePlayerControllable nothing from these functions?
Reply
#5

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
When is this DerbyPlayer[i] changed to a value higher than 0? Also, do you get frozen or nothing under the code there gets executed? No SCM, no PutPlayerInVehicle, no TogglePlayerControllable nothing from these functions?
Alright, I tried debugging it
When I tried to print DerbyVehicle[j] it told me "(null)" like the vehicle doesn't exist
And when I printed "j" it told me "0" like it's 0

The rest of the code works, SCM & Toggle works.

Debug code:
PHP код:
for(new vehicle 0vehicle 20vehicle++)
            {
                if(
IsVehicleOccupied(DerbyVehicle[vehicle])) continue;
                print(
DerbyVehicle[vehicle]);
                
printf("id: %d"vehicle); 
Console:
Код:
[04:24:50] (null) -- playerid 0
[04:24:50] id: 0  -- playerid 0
[04:24:50] (null) -- playerid 1
[04:24:50] id: 0 -- playerid 1
Reply
#6

And that is showed for all 20 vehicles?
Reply
#7

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
And that is showed for all 20 vehicles?
It looks like it doesn't detect DerbyVehicle[vehicle] as a vehicleid.
I tried doing DerbyVehicle[0] and it teleported me to the vehicle
Reply
#8

What would happen if you try to end the loop with return instead of break?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)