SA-MP Forums Archive
HELP +REP - 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: HELP +REP (/showthread.php?tid=573918)



HELP +REP - KingPersona - 11.05.2015

FIXED.


Re: HELP +REP - Crayder - 11.05.2015

pawn Код:
forward RACtime(); public RACtime()
{
    new bool:unwanted[CAR_AMOUNT];
    for(new player=0; player<MAX_PLAYERS; player++) if(IsPlayerInAnyVehicle(player))
        unwanted[GetPlayerVehicleID(player)]=true;
    for(new car = 1; car <= 420; car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(player))
        SetVehicleToRespawn(car);
}
I don't know wtf CAR_AMOUNT is, so this might not work... But if it's just a MAX_VEHICLES type of thing, then the following code will work perfect for 0.3.7:
pawn Код:
forward RACtime(); public RACtime()
{
    new bool:unwanted[CAR_AMOUNT];
    for(new player=0; player < GetPlayerPoolSize(); player++) if(IsPlayerInAnyVehicle(player))
        unwanted[GetPlayerVehicleID(player)]=true;
    for(new car; car < GetVehiclePoolSize(); car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(player))
        SetVehicleToRespawn(car);
}



Re: HELP +REP - Sithis - 12.05.2015

Please choose a proper topic title next time. A good title for this topic would be:
"How to get trailers not to respawn"


Re: HELP +REP - KingPersona - 14.05.2015

Quote:
Originally Posted by Crayder
Посмотреть сообщение
pawn Код:
forward RACtime(); public RACtime()
{
    new bool:unwanted[CAR_AMOUNT];
    for(new player=0; player<MAX_PLAYERS; player++) if(IsPlayerInAnyVehicle(player))
        unwanted[GetPlayerVehicleID(player)]=true;
    for(new car = 1; car <= 420; car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(player))
        SetVehicleToRespawn(car);
}
I don't know wtf CAR_AMOUNT is, so this might not work... But if it's just a MAX_VEHICLES type of thing, then the following code will work perfect for 0.3.7:
pawn Код:
forward RACtime(); public RACtime()
{
    new bool:unwanted[CAR_AMOUNT];
    for(new player=0; player < GetPlayerPoolSize(); player++) if(IsPlayerInAnyVehicle(player))
        unwanted[GetPlayerVehicleID(player)]=true;
    for(new car; car < GetVehiclePoolSize(); car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(player))
        SetVehicleToRespawn(car);
}
Thanks for help and ur answer , i get error(
Код:
error 017: undefined symbol "player"
pawn Код:
for(new car; car < GetVehiclePoolSize(); car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(player))
and i get warning in MAX_VEHICLES,
pawn Код:
warning 201: redefinition of constant/macro (symbol "MAX_VEHICLES")
i define it
pawn Код:
#define MAX_VEHICLES 600



Re: HELP +REP - Crayder - 14.05.2015

1.
pawn Код:
#undef MAX_VEHICLES
#define MAX_VEHICLES 600
2.
pawn Код:
for(new car; car < GetVehiclePoolSize(); car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(car))
Also, since you've redefined MAX_VEHICLES already, what is the point of CAR_AMOUNT? I bet you could just replace all instances of CAR_AMOUNT with MAX_VEHICLES.


Re: HELP +REP - KingPersona - 15.05.2015

Quote:
Originally Posted by Crayder
Посмотреть сообщение
1.
pawn Код:
#undef MAX_VEHICLES
#define MAX_VEHICLES 600
2.
pawn Код:
for(new car; car < GetVehiclePoolSize(); car++) if(!unwanted[car] || IsTrailerAttachedToVehicle(car))
Also, since you've redefined MAX_VEHICLES already, what is the point of CAR_AMOUNT? I bet you could just replace all instances of CAR_AMOUNT with MAX_VEHICLES.
Thanks, done trailer not respawn , and i replace all with CAR_AMOUNT TO MAX_VEHICLES, and now car is respawn if u are in car , and trailer no(!


Re: HELP +REP - Threshold - 15.05.2015

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
forward RACtime();
public RACtime()
{
    static vehID, trailerid;
    new bool:unwanted[CAR_AMOUNT char];

    for(new player=0; player<MAX_PLAYERS; player++)
        if(IsPlayerConnected(player))
        {
            vehID = GetPlayerVehicleID(player);
            if(!(0 < vehID < CAR_AMOUNT)) continue; // if player is not in any vehicle we skip
            unwanted{vehID} = true;

            trailerid = GetVehicleTrailer(vehID);
            if(0 < trailerid < CAR_AMOUNT) // if trailer is attached
                unwanted{trailerid} = true;
        }

    for(new car = 1; car < CAR_AMOUNT; car++)
        if(!unwanted{car} && GetVehicleModel(car) > 0) // or https://sampwiki.blast.hk/wiki/IsValidVehicle instead GetVehicleModel
            SetVehicleToRespawn(car);
}
Stick to one thread...


Re: HELP +REP - keyvanik - 15.05.2015

this is on my gamemode

PHP код:
    if(strcmp(cmd"/respawnallcars"true) == || strcmp(cmd"/rac"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pAdmin] <= 6)
            {
                
SendClientMessage(playeridCOLOR_GREEN"Error: You are not authorized to use this command.");
                return 
1;
            }
            for(new 
i;i<MAX_VEHICLES;i++)
            {
            if(
IsUnusedVehicle(i) && IsVehicleConnected(i) && OwnedMashin[i] == && OwnedMashin_2[i] == 0SetVehicleToRespawn(i);
            }
            
format(string,256,"All Vehicles Respawned By Owner %s",PINFO[playerid][pName]);
            
AdminWarn(string);
        }
        return 
1;
    } 



Re: HELP +REP - Smileys - 15.05.2015

PHP код:
stock RespawnAllVehicles( )
{
    for( new 
1<= GetVehiclePoolSize( ); i++ ) //vehicle IDs start at 1.
    
{
        for( new 
0<= GetPlayerPoolSize( ); p++ ) // looping through connected players
        
{
            if( 
IsPlayerInVehiclep) ) // if someone's driving the current vehicle we're checking 
                
continue; // exit the player loop as we don't need to check any further
        
}
        if( 
IsVehicleTrailer) && IsVehicleAttachedToTrailer) ) // if it's a trailer, and if it's attached to some vehicle
            
continue; // tell the loop to continue on to the next vehicle as this one is a trailer attached to a vehicle 
        
SetVehicleToRespawn); // respawn the vehicle if it's unoccupied and not attached to any vehicle 
    
}
    return 
1;
}
IsVehicleTrailervehicleid )
{
    switch( 
GetVehicleModelvehicleid ) )
    {
        case 
435450584591: return true// if it's a trailer
        
default: return false// if not
    
}
    return 
false// return false by default
}
IsVehicleAttachedToTrailertrailerid )
{
    for( new 
1GetVehiclePoolSize( ); i++ )
    {
        if( 
GetVehicleTrailer) == trailerid // if the trailer attached to this vehicle is the trailer
            
return true;
    }
    return 
false;

Untested, but should work


Re: HELP +REP - KingPersona - 15.05.2015

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Stick to one thread...
Thanks + rep , and Crayder Thanks +rep.