SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 30/03/2011, 01:07 PM   #1
Madsen
Big Clucker
 
Join Date: Jan 2011
Posts: 151
Reputation: 0
Default auto repair

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
Madsen is offline  
Old 30/03/2011, 01:13 PM   #2
HyperZ
High-roller
 
HyperZ's Avatar
 
Join Date: Aug 2009
Location: Islamabad, Pakistan
Posts: 1,341
Reputation: 66
Default Re: auto repair

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;
}
HyperZ is offline  
Old 30/03/2011, 01:14 PM   #3
Žilvėnas
Big Clucker
 
Žilvėnas's Avatar
 
Join Date: Mar 2011
Location: Lithuania
Posts: 54
Reputation: 0
Default Re: auto repair

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 :]
Žilvėnas is offline  
Old 30/03/2011, 02:32 PM   #4
xerox8521
Big Clucker
 
Join Date: Nov 2010
Posts: 128
Reputation: 3
Default AW: Re: auto repair

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

 
}
__________________
Code:
GameModes
xerox8521 is offline  
Old 30/03/2011, 03:13 PM   #5
Madsen
Big Clucker
 
Join Date: Jan 2011
Posts: 151
Reputation: 0
Default Re: auto repair

it still does not work :O?
Madsen is offline  
Old 30/03/2011, 03:17 PM   #6
Zh3r0
High-roller
 
Join Date: Mar 2008
Posts: 4,510
Reputation: 398
Default Re: auto repair

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
__________________
Zh3r0 is offline  
Old 30/03/2011, 08:58 PM   #7
Madsen
Big Clucker
 
Join Date: Jan 2011
Posts: 151
Reputation: 0
Default Re: auto repair

hmm, ty
Madsen is offline  
Old 31/03/2011, 07:28 AM   #8
Madsen
Big Clucker
 
Join Date: Jan 2011
Posts: 151
Reputation: 0
Default Re: auto repair

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 -_-
Madsen is offline  
Old 01/04/2011, 08:24 PM   #9
Madsen
Big Clucker
 
Join Date: Jan 2011
Posts: 151
Reputation: 0
Default Re: auto repair

can anyone tell me why its only the first one that join the autorepair thing works for :S?
Madsen is offline  
Old 01/04/2011, 09:32 PM   #10
Madsen
Big Clucker
 
Join Date: Jan 2011
Posts: 151
Reputation: 0
Default Re: auto repair

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;
    }
Madsen is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Auto Repair/Auto Flip [FS] BLAbla93 Filterscripts 29 22/11/2012 10:49 AM
[FilterScript] [FS]Auto repair reallifescript Filterscripts 11 24/03/2011 09:53 PM
auto repair fs help.... deviljingoku Help Archive 6 19/03/2011 08:43 PM


All times are GMT. The time now is 05:00 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.