[Tutorial] Simple Auto-Repair
#1

NOTE TO ALL: I ain't no MASTER Scripter but I ain't no beginner either. I know what I put in my scripts, and if you don't like the tutorials I make and you just came to critisize rather than to correct or alert of mis-input , Please, Leave now.

Hey! I decided to make a small tutorial on how to make a very, very, very, very simple auto repair code.

Its not a filterscript but to be incorperated in your gamemode/own FS whatever...
All you do at the top of the script add:
pawn Код:
forward Rep(); //You can change Rep to anything you like
What this is, it is a forward to create a public function.

Now at the end of your script add
pawn Код:
public Rep() //Change "Rep" to whatever you named at forward. This is important
{
    for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) RepairVehicle(GetPlayerVehicleID(i));
}
Corrected by NeTuddMeg
This is what is called when this public function happens.

Now how does this function activate? A timer!
Under OnGameModeInit() add:
pawn Код:
SetTimer("Rep",1000,true); //Change "Rep" to whatever you named at forward. This is important.
This is the timer that calls our function!
It is a 1sec timer. It's in milliseconds you can change time to whatever you please.

Thats it! When you're done it should look something like this.
pawn Код:
#include <a_samp>
forward Rep(playerid,vehicleid);
public OnGameModeInit()
{
       SetTimer("Rep",1000,true);
}
public Rep(playerid,vehicleid)
{
    vehicleid = GetPlayerVehicleID(playerid);
    RepairVehicle(vehicleid);
}
I just had this snippet in my GM so I decided to share it. It is simpler than downloading a mega complexed Auto-Repair FS. It works 100%

I hope this helps! +Rep if this was useful and not a repost of someone else's tutorial.. :S
(I'm sorry if this is a repost. I didn't decide to look because I made this on my own so...)
(Simpler way Pending.........)
Reply


Messages In This Thread
Simple Auto-Repair - by Jagofr - 01.03.2012, 01:57
Re: Simple Auto-Repair - by Deathlane - 01.03.2012, 09:55
Re: Simple Auto-Repair - by T0pAz - 01.03.2012, 10:10
Re: Simple Auto-Repair - by NeTuddMeg - 01.03.2012, 10:13
Re: Simple Auto-Repair - by Jagofr - 04.03.2012, 18:22
Re : Simple Auto-Repair - by mehdi-jumper - 06.03.2012, 12:07
Re: Re : Simple Auto-Repair - by Max_Coldheart - 06.03.2012, 15:32
Re: Re : Simple Auto-Repair - by wups - 06.03.2012, 15:51
Re : Simple Auto-Repair - by mehdi-jumper - 06.03.2012, 17:04
Re: Simple Auto-Repair - by Jagofr - 10.03.2012, 01:52

Forum Jump:


Users browsing this thread: 1 Guest(s)