Vehicle-related Question
#1

Is it possible to loop through all vehicles, engine activated or not? See, I'm making this system and somewhere in it, it requires all created vehicles to be teleported somewhere.
Reply
#2

Quote:
Originally Posted by NealPeteros
Посмотреть сообщение
Is it possible to loop through all vehicles, engine activated or not?
Yes, of course it is...All vehicles have an ID, and there is MAX_VEHICLES, or GetVehiclePoolSize.

Engine being activated has nothing to do with it.
Reply
#3

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Yes, of course it is...All vehicles have an ID, and there is MAX_VEHICLES, or GetVehiclePoolSize.

Engine being activated has nothing to do with it.
Am I doing something wrong here?
PHP код:
for(new iGetVehiclePoolSize()+1i++)
    {
        if( 
GetVehicleMass) >= 2400.0 )
        {
            
SetVehicleAngularVelocityi0.050.30.08 );
        }
        else
        {
            
SetVehicleAngularVelocityi0.0150.150.15 );
        }
    } 
It doesn't create the effect.
Reply
#4

Also receiving these

Код:
[16:14:01] [debug] Run time error 4: "Array index out of bounds"
[16:14:01] [debug]  Accessing element at negative index -400
[16:14:01] [debug] AMX backtrace:
[16:14:01] [debug] #0 0002bf38 in ?? (0) from gm.amx
[16:14:01] [debug] #1 0018801c in public TestEffect () from gm.amx
TestEffect:
PHP код:
public TestEffect(playerid)
{
    switch(
random(3))
    {
        case 
0:
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOTSetPlayerVelocity(playerid0.030.00.05);
        }
            case 
1:
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOTSetPlayerVelocity(playerid0.050.00.02);
        }
            case 
2:
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOTSetPlayerVelocity(playerid0.010.050.03);
        }
    }
    for(new 
vidvid GetVehiclePoolSize()+1vid++)
    {
        if( 
GetVehicleMassvid ) >= 2400.0 ){
                
SetVehicleAngularVelocityvidqmag 0.03qmag 0.03qmag 0.03 );
            } else 
SetVehicleAngularVelocityvidqmag 0.05qmag 0.05qmag 0.05 );
    }
    new 
qint floatround(qmag floatround_round);
    
SetPlayerDrunkLevel(playeridqint10000);
    return 
1;

Reply
#5

Код:
for(new vid; vid < GetVehiclePoolSize()+1; vid++)
Don't use it like that, use it as is shown on the wiki as per the example.

Код:
for(new i = 1, j = GetVehiclePoolSize(); i <= j; i++)
If you're wanting to isolate the problem in it, maybe you shouldn't load up the function with other purposes than the vehicles.
Reply
#6

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
If you're wanting to isolate the problem in it, maybe you shouldn't load up the function with other purposes than the vehicles.
Uh, would you mind to explain a bit more?
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Код:
for(new i = 1, j = GetVehiclePoolSize(); i <= j; i++)
Still doesn't work. Nevermind, just leave this, I give up, lol. Anyway, it's not a big of a deal if this works or not. Thanks anyway
Reply
#8

Ah well, if you give up that easily, then obviously you're not interested in learning how to go further.

You've got playerstates, and other checks in that function... It wouldn't be that hard to remove those, and isolate the issue.

If the error came back exactly the same when you used the example code, then chances are the error could be in another section of that function.



Hence why I said why do you have all that crud in there...
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Ah well, if you give up that easily, then obviously you're not interested in learning how to go further.

You've got playerstates, and other checks in that function... It wouldn't be that hard to remove those, and isolate the issue.

If the error came back exactly the same when you used the example code, then chances are the error could be in another section of that function.



Hence why I said why do you have all that crud in there...
Decided to continue, found out that these were causing the debug errors

PHP код:
new GetPlayerVehicleID(playerid);
    if( 
GetVehicleMass) >= 2400.0 )
    {
        
SetVehicleAngularVelocityi0.050.30.08 );
    }
    else
    {
        
SetVehicleAngularVelocityi0.0150.150.15 );
    } 
And


PHP код:
new vid GetPlayerVehicleID(playerid);
    if( 
GetVehicleMassvid ) >= 2400.0 ){
            
SetVehicleAngularVelocityvid0.030.030.03 );
    } else 
SetVehicleAngularVelocityvid0.0150.0150.015 ); 
EDIT: Found the fix. All engines are automatically off. Velocity won't change if the engines are off.
Reply
#10

Awesome... Good on you for actually pushing on, and finding the reason for your problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)