Disable Auto Repair/Fix Vehicle in Derby
#1

So I have an auto repair timer.


Код:
forward Rep(playerid,vehicleid);
Код:
SetTimerEx("VRepair",500,true,"i",playerid);
Код:
forward VRepair(playerid);
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid)) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
But how to disable that if I am in a derby deathmatch?

pawn Код:
CMD:derby(playerid, params[])
{
   if(GetPVarInt(playerid, "CMDDisabled") != 0)
   {
   ShowPlayerDialog(playerid, DIALOG_EVADE, DIALOG_STYLE_MSGBOX, "Leave Menu", "You must Leave first before using this command", "Leave", "Cancel");
   return 1;
   }
   if(!IsPlayerInAnyVehicle(playerid)){
   SetPlayerPos(playerid, -1398.103515,937.631164,1038.479125); //Height changed
   SetPlayerFacingAngle(playerid, 0.0);
   SetPlayerVirtualWorld(playerid, 15);
   SetPlayerInterior(playerid, 15);
   SetCameraBehindPlayer(playerid);
   new string[128], pName[MAX_PLAYER_NAME];
   GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
   format(string, sizeof(string), "{6666FF}(/derby) {00CCFF}%s {6666FF}has Teleported to The Derby",pName);
   SendClientMessageToAll(0xFFFFFFFF, string);
   pInEvent[playerid] = 1;
   SetPVarInt(playerid, "CMDDisabled", 2);
   }
   else{
       new string[128], pName[MAX_PLAYER_NAME];
       GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
       format(string, sizeof(string), "{6666FF}(/derby) {00CCFF}%s {6666FF}has Teleported to The Derby",pName);
       SendClientMessageToAll(0xFFFFFFFF, string);
       new veh = GetPlayerVehicleID(playerid);
       SetVehicleZAngle(veh, 0.0);
       SetVehiclePos(veh, -1398.103515,937.631164,1036.479125);
       SetCameraBehindPlayer(playerid);
       LinkVehicleToInterior(veh, 15);
       SetVehicleVirtualWorld(veh, 15);
       PutPlayerInVehicle(playerid, veh, 0);
   }
   pInEvent[playerid] = 1;
   SetPVarInt(playerid, "CMDDisabled", 2);
   return GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~The Derby",2000,3);
}
My command for derby..
Reply
#2

Create a new global variable:

new IsInDerby[MAX_PLAYERS];

Inside your command to enter the derby - IsInDerby[playerid] = 1;

When they exit, IsInDerby = 0;

Then update your repair function:

pawn Код:
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && IsInDerby[playerid] == 1) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
Reply
#3

Quote:
Originally Posted by phillip875
Посмотреть сообщение
Create a new global variable:

new IsInDerby[MAX_PLAYERS];

Inside your command to enter the derby - IsInDerby[playerid] = 1;

When they exit, IsInDerby = 0;

Then update your repair function:

pawn Код:
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && IsInDerby[playerid] == 1) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
Sorry still not working. If you have time can you do it for me?? thanks!
Reply
#4

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Sorry still not working. If you have time can you do it for me?? thanks!
pawn Код:
new bool:n_szIsPlayerInDerby[ MAX_PLAYERS ]; // at top

n_szIsPlayerInDerby[ playerid ] = false; // in OnPlayerConnect and OnPlayerDisconnect and in EXIT COMMAND

n_szIsPlayerInDerby[ playerid ] = true; // in the command to ENTER derby

forward VRepair( playerid );
public VRepair( playerid )
{
    if(IsPlayerInAnyVehicle(playerid) && !n_szIsPlayerInDerby[ playerid ] ) // if player is in vehicle and he is NOT in derby
    {
        RepairVehicle( GetPlayerVehicleID( playerid ) );
    }
}
else if you're using one variable for all events then:

pawn Код:
forward VRepair( playerid );
public VRepair( playerid )
{
    if(IsPlayerInAnyVehicle(playerid) &&  pInEvent[ playerid ] == 0 ) // if player is in vehicle and he is NOT in event
    {
        RepairVehicle( GetPlayerVehicleID( playerid ) );
    }
}
Reply
#5

Replace it...
pawn Код:
forward VRepair(playerid);
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && pInEvent[playerid] == 0 ) return RepairVehicle(GetPlayerVehicleID(playerid));
}
Reply
#6

I have tried both in it's all working thank so much! appreciate your help. + rep you three
Reply
#7

Got problem it automatically repair vehicle. If im shooting the tires it repairs automatically, but when I do hit the car on the walls the bumper falls or (damaged) and no smoke and fire.
Reply
#8

Explain as better as you can.
Reply
#9

Quote:
Originally Posted by leonardo1434
Посмотреть сообщение
Explain as better as you can.
So my friend and I teleport to derby to check if the codes above are working.. First my friend enter the vehicle, I tried to shoot the vehicles (at first the tires get's flat after second it fixed automatically like nothing happened)

Then we noticed that every time we hit the bumper through the walls or any part of the vehicle it do damages. And hitting many times on the wall or vehicles don't coz fire or smoke.

What's the difference at all??
Reply
#10

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Then we noticed that every time we hit the bumper through the walls or any part of the vehicle it do damages
Vehicle parts that can fall off requires the vehicle to be a little bit damaged in order to be repaired.

This does work:
pawn Код:
SetVehicleHealth(tmpcar, 950); // So hoods and doors come back even if the damage was minor.
RepairVehicle(tmpcar); // Repairs the whole vehicle, regardless of health. Unless the vehicle is dead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)