auto repair
#1

hey i am trying to make a auto repair system for my server but it does not work here is what i have done


pawn Code:
new autorepair[MAX_PLAYERS];

forward OnVehicleDamage(playerid);

public OnVehicleDamage(playerid)
{
    new Float:health, cid;
   
    if(autorepair[playerid] == 1)
    {
        if (!IsPlayerInAnyVehicle(playerid))
        {
            cid = GetPlayerVehicleID(playerid);
            GetVehicleHealth(cid, health);
            {
                if (health < 500)
                {
                SetVehicleHealth(cid, 1000);
                }
            }
        }
    }
    return 1;
}
public OnGameModeInit()
pawn Code:
SetTimer("OnVehicleDamage", 1000, 1);

pawn Code:
if (strcmp("/racemap", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, 5070.8862304688, -2250.9711914063, 403.73211669922+1);
        SendClientMessage(playerid, COLOR_ORANGE, " Thank Speederx for making the race/stunt map");
        autorepair[playerid] = 1;
        return 1;
    }
i get 0 errors but in game it does not work
Reply
#2

pawn Code:
public OnVehicleDamage(playerid)
{
    new Float:VHealth, vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid,VHealth);
    if(autorepair[playerid] == 1)
    {
        if (!IsPlayerInAnyVehicle(playerid))
        {
            if(autorepair[playerid] == 1)
            {
                if(VHealth < 500)
                {
                    SetVehicleHealth(vehicleid,1000);
                }
            }
        }
    }
    return 1;
}
Reply
#3

WAIT

Code:
if (strcmp("/racemap", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, 5070.8862304688, -2250.9711914063, 403.73211669922+1);
        SendClientMessage(playerid, COLOR_ORANGE, " Thank Speederx for making the race/stunt map");
         GetVehicleHealth(playerid, 100);
        return 1;
    }
Try this.But..it's simple.And well :]
Reply
#4

Quote:
Originally Posted by Clive
View Post
pawn Code:
public OnVehicleDamage(playerid)
{
    new Float:VHealth, vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid,VHealth);
    if(autorepair[playerid] == 1)
    {
        if (!IsPlayerInAnyVehicle(playerid))
        {
            if(autorepair[playerid] == 1)
            {
                if(VHealth < 500)
                {
                    SetVehicleHealth(vehicleid,1000);
                }
            }
        }
    }
    return 1;
}
Replace the

pawn Code:
public OnVehicleDamage(playerid)
{
                    SetVehicleHealth(vehicleid,1000);
 
}
to
pawn Code:
public OnVehicleDamage(playerid)
{
                    RepairVehicle(vehicleid);
// things like Doors / Tires get fixed too( Visible Damage)
// Health get set to 1000 too

 
}
Reply
#5

it still does not work :O?
Reply
#6

It's because you are checking if the player is NOT(!) in the vehicle! Notice the '!' Exclamation Point near the function, that means the opposite of what it should do, so it check if he is NOT.

So delete the ! from the front of the function of IsPlayerInAnyVehicle
Reply
#7

hmm, ty
Reply
#8

Quote:
Originally Posted by Zh3r0
View Post
It's because you are checking if the player is NOT(!) in the vehicle! Notice the '!' Exclamation Point near the function, that means the opposite of what it should do, so it check if he is NOT.

So delete the ! from the front of the function of IsPlayerInAnyVehicle
thx alot it works now , i even asked my friend about it and he just said it was right -_-
Reply
#9

can anyone tell me why its only the first one that join the autorepair thing works for :S?
Reply
#10

it looks like this now:
pawn Code:
//at the top
new autorepair[MAX_PLAYERS];
pawn Code:
forward AutoR(playerid);

public AutoR(playerid)
{
    new Float:VHealth, vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid,VHealth);
    if(autorepair[playerid] == 1)
    {
        if (IsPlayerInAnyVehicle(playerid))
        {
            if(VHealth < 999)
            {
            RepairVehicle(vehicleid);
            }
        }
    }
    return 1;
}
onplayercommand
pawn Code:
if (strcmp("/offroadmap", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, -2644, -2130, 1704+1);
        SendClientMessage(playerid, COLOR_ORANGE, "Thank Thanator for making the offroad road");
        autorepair[playerid] = 1;
        SetPlayerCheckpoint(playerid, 79.8441, -1531.5741, 2413.0000, 5);
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)