What is wrong with it?
#1

I wanna make a command to respawn a specific car ( Chasecar).
When I type /rcc the Chasecar destroyed but it doesn't respawn. What is wrong with it
pawn Код:
new ccar;
OnFilterScriptInit
pawn Код:
for(new i=0; i<MAX_VEHICLES; i++)  //loop
    {
        if(i == ccar) //if i == ccar
        {
            SetVehicleNumberPlate(i, "ChaseMe"); //sets the cars number plate
            SetVehicleToRespawn(i); //respawns it (VERY IMPORTANT!!!)
        }
    }
    ccar = AddStaticVehicle(411,x,y,z,rot,146,146); // ccar
    SetTimer("ccc", 500, 1); //sets the timer
    return 1;
}
OnPlayerCommandText
pawn Код:
if (strcmp(cmd, "/rcc", true) == 0)
    {
        for(new i=0; i<MAX_VEHICLES; i++)  //loop
        {
            if(i == ccar) //if i == ccar
            {
                DestroyVehicle(i);
                SetVehicleToRespawn(i);
                SendClientMessageToAll(0xFF0000FF, "The ChaseCar Respawned!!!");
            }
        }
        return 1;
    }
OnVehicleSpawn
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    if(vehicleid == ccar)
    {
        AddVehicleComponent(vehicleid, 1097); // Rim Virtual
        AddVehicleComponent(vehicleid, 1010); // Nitrous x10 times
        SendClientMessageToAll(0xFF0000FF, "The ChaseCar Respawned!!!"); //Respawn message
    }
    return 1;
}
Reply
#2

please!
I need a help with this.
Reply
#3

Remove DestroyVehicle.
Reply
#4

Remove DestroyVehicle and the loops because they're unneeded AFAIK. If it doesn't work without the loops (i haven't coded for a long time so i dont remember exactly) just readd them.
pawn Код:
new ccar;
OnFilterScriptInit
pawn Код:
ccar = AddStaticVehicle(411,x,y,z,rot,146,146); // ccar
    SetVehicleNumberPlate(ccar, "ChaseMe"); //sets the cars number plate
    SetVehicleToRespawn(ccar); //respawns it (VERY IMPORTANT!!!)
    SetTimer("ccc", 500, 1); //sets the timer
    return 1;
}
OnPlayerCommandText
pawn Код:
if (strcmp(cmd, "/rcc", true) == 0)
{
    SetVehicleToRespawn(ccar);
    SendClientMessageToAll(0xFF0000FF, "The ChaseCar Respawned!!!");
    return 1;
}
OnVehicleSpawn
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    AddVehicleComponent(ccar, 1097); // Rim Virtual
    AddVehicleComponent(ccar, 1010); // Nitrous x10 times
    SendClientMessageToAll(0xFF0000FF, "The ChaseCar Respawned!!!"); //Respawn message
    return 1;
}
Reply
#5

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Remove DestroyVehicle.
Thanks, my bad. I thought that it will destroy it and spawn it again.
Anyway rep +

---------------------------------------------------

Also, another problem I have with this is that I have a Timer, when a player exit the vehicle, the vehicle it destroyed.
This happens for everycar, so I want to KillTimer on Chasecar. I tried a lot of things but because it's SetTimerEx, I can't KillTimer. If I kill the timer, the autofix (that I killed with timer) doesn't work on chasecar and the chasecar repair.
Here is OnPlayerExitVehicle
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
//  new currentveh;
//  currentveh = GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER) {
        DestroyVehicle(vehicleid);                //thats supposed to be in the timer. no slapping out
    }
//  TextDrawShowForPlayer(playerid,Cardestroyed);
//  SetTimerEx("cardestroyedhide", 5000, 0, "i", playerid);
    SetTimerEx("cardestroyedhide", 5000, 0, "i", vehicleid);
    if(vehicleid == ccar) //if vehicleid == ccar
    {
        new name[MAX_PLAYER_NAME], string[44]; //defines name and string
        GetPlayerName(playerid, name, sizeof(name)); //gets the players name
        format(string, sizeof(string), "%s has left the ChaseCar!",name); //formats the message
        SendClientMessageToAll(0xFF0000FF, string); //sends the message
        SetTimer("AutoFix", 1000, true);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)