auto repair - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: auto repair (
/showthread.php?tid=147924)
auto repair -
Kar - 15.05.2010
hey i was wondering if someone could make me a car auto repairer.. like every 30 secs it repairs the car or something... and i could type /r to repair it
Re: auto repair -
Assyria - 15.05.2010
Go to: "Scripting Request Thread" and ask there.
Re: auto repair -
Assyria - 15.05.2010
Oh what the heck, since its 7.12 in the morning and whole night been wake, I created you somekinda autorepairer, I will not succesfully reveice complainings.
Code:
#include <a_samp>
new Repair;
public OnFilterScriptInit()
{
Repair = SetTimer("Repairer",1000, true); // This is 1 second, if you want 30 seconds, change the number "1000" to "30000"
return 1;
}
public OnFilterScriptExit()
{
KillTimer(Repair);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/repair", cmdtext, true, 10) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFAA,"You are not in vehicle!");
{
SendClientMessage(playerid,0xFFFFFFAA,"You repaired the car!");
SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
}
return 1;
}
return 0;
}
forward Repairer();
public Repairer()
{
for(new i =0; i < MAX_PLAYERS; i++)
{
new car = GetPlayerVehicleID(i);
if(!IsPlayerInAnyVehicle(i)) return
SetVehicleHealth(GetPlayerVehicleID(i), 1000);
RepairVehicle(car);
}
return 1;
}
Atleast your car is now looking good and don't explode anymore

Sleep

Edit: Sorry for double post, im really too tired
Re: auto repair -
Kar - 15.05.2010
is it a filterscript?
Re: auto repair -
juice.j - 15.05.2010
It is.
You might check tho' on recursion as you really don't need to call the function once again in it.
Re: auto repair -
Kar - 15.05.2010
when i compile it says "function "repairer" shoudl have a return value" & "function uses both "return and "return" <value>"
help:\
Code:
#include <a_samp>
new Repair;
public OnFilterScriptInit()
{
Repair = SetTimer("Repairer",5000, true);
return 1;
}
public OnFilterScriptExit()
{
KillTimer(Repair);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/r", cmdtext, true, 10) == 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFFFFFAA,"You are not in vehicle!");
{
SendClientMessage(playerid,0xFFFFFFAA,"car repaired!");
SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
}
return 1;
}
return 0;
}
forward Repairer();
public Repairer()
{
for(new i =0; i < MAX_PLAYERS; i++)
{
new car = GetPlayerVehicleID(i);
if(!IsPlayerInAnyVehicle(i)) return
SetVehicleHealth(GetPlayerVehicleID(i), 1000);
RepairVehicle(car);
}
return 1;
}
when i compile it gives me function