repsawn car
#1

if a player drive a car and come on the road and /q the game and i want if no one touch this car so after 10mins the car auto respawn where i added spawn places on my script. so any idea?
Reply
#2

Use

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        SetTimerEx("QuitDestroy", 600000, false, "i", GetPlayerVehicleID(playerid));
    }
    return 1;
}

forward QuitDestroy(vehicleid);
public QuitDestroy(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerVehicleID(i) != vehicleid)
            {
                DestroyVehicle(vehicleid);
            }
        }
    }
}
Should work, just tested it and it did for me.
Reply
#3

^ SetVehicleToRespawn(vehicleid);
Reply
#4

thanx to getty but getty this is just destroy codes and i want the car respawn again? and jewell explain more please.
Reply
#5

nothing work getty i put timer on 1mins and i /q my game and login again after 1 mins and still car have
Reply
#6

actually, iGetty's code great but it has a little mistake, atfer 10 min it will destroy every other vehicles which has a driver.. xD

make a little changes

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        SetTimerEx("QuitDestroy", 600000, false, "i", GetPlayerVehicleID(playerid));
    }
    return 1;
}
I'm not sure this code works or not, i couldn't test it, let's have a try
pawn Код:
forward QuitDestroy(vehicleid);
public QuitDestroy(vehicleid)
{
    new Inveh = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) {continue;}
        if(!IsPlayerInAnyVehicle(i)) {continue;}
        if(GetPlayerVehicleID(i) == vehicleid)
        {
                Inveh = 1;
        }
    }
    if(Inveh == 0) SetVehicleToRespawn(vehicleid);
}
Reply
#7

thanx let me check.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)