Simple Auto-Repair -
Jagofr - 01.03.2012
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.........)
Re: Simple Auto-Repair -
Deathlane - 01.03.2012
Nice one... This is much better than pressing 2... Anyways this is so easy to make... Well, anyways nice
Re: Simple Auto-Repair - T0pAz - 01.03.2012
vehicleid parameter is not needed and you haven't explained it well about the function and native. Please
learn how to script first then make a tutorial.
Re: Simple Auto-Repair -
NeTuddMeg - 01.03.2012
hmm.. WTF!
Код:
#include <a_samp>
forward Rep();
public OnGameModeInit()
{
SetTimer("Rep",1000,true);
}
public Rep()
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) RepairVehicle(GetPlayerVehicleID(i);
}
Re: Simple Auto-Repair -
Jagofr - 04.03.2012
Quote:
Originally Posted by ObelesMarc
Nice one... This is much better than pressing 2... Anyways this is so easy to make... Well, anyways nice
|
Thanks so much.
Quote:
Originally Posted by T0pAz
vehicleid parameter is not needed and you haven't explained it well about the function and native. Please learn how to script first then make a tutorial.
|
Explain what really is the problem here because I use the script, everyone that joins my server has the same outcome so I don't see what is the problem with this script.
Quote:
Originally Posted by NeTuddMeg
hmm.. WTF!
pawn Код:
#include <a_samp> forward Rep(); public OnGameModeInit() { SetTimer("Rep",1000,true); } public Rep() { for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) RepairVehicle(GetPlayerVehicleID(i)); }
|
I see.. This is so that the Timer doesn't loop if anyone isn't connected.. Thanks for the correct. I'll edit the tutorial.
Re : Simple Auto-Repair -
mehdi-jumper - 06.03.2012
This is not very good but it work.
It's beter if you use the callback OnVehicleDamageUpdate this is the best way because if you use a timer that may slow down your serveur.
Otherwise good job
Re: Re : Simple Auto-Repair -
Max_Coldheart - 06.03.2012
Quote:
Originally Posted by mehdi-jumper
This is not very good but it work.
It's beter if you use the callback OnVehicleDamageUpdate this is the best way because if you use a timer that may slow down your serveur.
Otherwise good job 
|
Which (recording to the documentation) doesn't exist.
Re: Re : Simple Auto-Repair -
wups - 06.03.2012
Quote:
Originally Posted by Jagofr
pawn Код:
#include <a_samp> forward Rep(playerid,vehicleid); public OnGameModeInit() { SetTimer("Rep",1000,true); } public Rep(playerid,vehicleid) { vehicleid = GetPlayerVehicleID(playerid); RepairVehicle(vehicleid); }
.... It works 100%
|
No it doesn't! Your code is invalid.
Quote:
Originally Posted by CookieJar
Which (recording to the documentation) doesn't exist.
|
It's OnVehicleDamage
StatusUpdate.
Re : Simple Auto-Repair -
mehdi-jumper - 06.03.2012
Quote:
t's OnVehicleDamageStatusUpdate.
|
Yes it is !
Re: Simple Auto-Repair -
Jagofr - 10.03.2012
Ill do my research guys.. Thanks for the tips..