#1

Heloo i need help with a cmd:
Код:
CMD:respawnall(playerid,params[])
{
	new string[128];
        if(APlayerData[playerid][PlayerLevel] < 4) return SendClientMessage(playerid, 0xFF0000FF, "Nu ai level neceasr!");
        for(new car = 1; car <= 1999; car++)
        {
                if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        }
        //GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Adminul %s a respawnat toate masinile.", pName(playerid));
        SendClientMessageToAll(COLOR_ROYALBLUE,string);
        return 1;
}
 
stock IsVehicleEmpty(vehicleid)
{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
                if(IsPlayerInVehicle(i, vehicleid)) return 0;
        }
        return 1;
}
How I can make it to not respawn trailers who is in use?Beacuse this respawn and trailers who attached to a truck
Reply
#2

Hello!

Here you are. Look, what I changed.

PHP код:
CMD:respawnall(playerid,params[])
{
    new 
string[145];
    if(
APlayerData[playerid][PlayerLevel] < 4)return SendClientMessage(playerid0xFF0000FF"Nu ai level neceasr!");
    for(new 
car=1;car<=1999;car++)
    {
        if(
GetVehicleTrailer(car) > 0)continue;
        if(
IsVehicleEmpty(car)) SetVehicleToRespawn(car);
    }
    
//GetPlayerName(playerid, sendername, sizeof(sendername));
     
format(stringsizeof(string), "Adminul %s a respawnat toate masinile."pName(playerid));
     
SendClientMessageToAll(COLOR_ROYALBLUE,string);
     return 
1;

Reply
#3

It doesn't work, keep respawn the trailer which is attached , but now make little lag
Reply
#4

Use https://sampwiki.blast.hk/wiki/IsTrailerAttachedToVehicle

Should solve your issue.
Reply
#5

Quote:
Originally Posted by itsCody
Посмотреть сообщение
That function just check if a vehicle has a trailer attached.

You need to loop through every vehicle to see if the trailer is attached.
Use this custom function :
Код:
CMD:respawnall(playerid,params[])
{
	new string[128], vmod;
        if(APlayerData[playerid][PlayerLevel] < 4) return SendClientMessage(playerid, 0xFF0000FF, "Nu ai level neceasr!");
        for(new car = 0; car <= GetVehiclePoolSize(); car++)
        {
                vmod = GetVehicleModel(car);
                if(vmod == 435 || vmod == 450 || vmod == 584) // Check if it's a trailer
                {
                        if(!IsTrailerAttached(car))
                                SetVehicleToRespawn(car)
                }
                else
                        if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
        }
        //GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Adminul %s a respawnat toate masinile.", pName(playerid));
        SendClientMessageToAll(COLOR_ROYALBLUE,string);
        return 1;
}
 
stock IsVehicleEmpty(vehicleid)
{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
                if(IsPlayerInVehicle(i, vehicleid)) return 0;
        }
        return 1;
}

stock IsTrailerAttached(trailerid)
{
        for(new i = 0; i <= GetVehiclePoolSize(); i++)
        {
                if(GetVehicleTrailer(i) == trailerid) // Check if this trailer attached to another vehicle
                {
                        return true;
                }
        }
        return false;
}
Reply
#6

Quote:
Originally Posted by X337
Посмотреть сообщение
That function just check if a vehicle has a trailer attached.

You need to loop through every vehicle to see if the trailer is attached.
Well, he was saying that every vehicle (including attached trailers) were being respawned. So using that to check if it's attached to a vehicle won't make the trailer respawn.
Reply
#7

Quote:
Originally Posted by itsCody
Посмотреть сообщение
Well, he was saying that every vehicle (including attached trailers) were being respawned. So using that to check if it's attached to a vehicle won't make the trailer respawn.
That function is to check if a vehicle has a trailer attached.
Not to check if a trailer is attached to vehicle.
Reply
#8

Thanks alot @X337 , it's worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)