SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 15/05/2010, 01:55 AM   #1
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,938
Reputation: 538
Default auto repair

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
Kar is offline  
Old 15/05/2010, 03:49 AM   #2
Assyria
Huge Clucker
 
Join Date: Mar 2010
Posts: 209
Reputation: 0
Default Re: auto repair

Go to: "Scripting Request Thread" and ask there.
__________________
I have stopped with SA:MP, just due some lame-ass reason. Also, MTA is WAY better than SA:MP, I can comment it to you! Download: www.mtasa.com
Assyria is offline  
Old 15/05/2010, 04:10 AM   #3
Assyria
Huge Clucker
 
Join Date: Mar 2010
Posts: 209
Reputation: 0
Default Re: auto repair

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
__________________
I have stopped with SA:MP, just due some lame-ass reason. Also, MTA is WAY better than SA:MP, I can comment it to you! Download: www.mtasa.com
Assyria is offline  
Old 15/05/2010, 01:06 PM   #4
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,938
Reputation: 538
Default Re: auto repair

is it a filterscript?
Kar is offline  
Old 15/05/2010, 01:12 PM   #5
juice.j
Huge Clucker
 
Join Date: May 2010
Posts: 214
Reputation: 0
Default Re: auto repair

It is.

You might check tho' on recursion as you really don't need to call the function once again in it.
__________________
SA:MP Freelancer Portfolio:

GameMode / Filterscript / Plugin Development via
- PAWN / C/C++
- Database (mySQL) & Filebased - Systems

Webdevelopment / Interfaces Webapplications - SA:MP Server via
- HTML & CSS
- PHP, JavaScript, Ajax

Interested in a unique, high quality gamemode using modern code and c++-plugins? A control panel giving you the opportunity to do literally everything on your server from a browser?

Contact Info: juice.j.122@hotmail.com
juice.j is offline  
Old 15/05/2010, 01:39 PM   #6
Kar
Banned
 
Join Date: May 2010
Location: Black Asylum
Posts: 2,938
Reputation: 538
Default Re: auto repair

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
Kar 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
vehicle auto-repair timer wangdata Help Archive 6 28/01/2010 08:54 AM
[FilterScript] [FS] Auto Repair ~ Great for stunt servers! Klutty Filterscripts 9 11/04/2009 04:38 PM
[HELP] Auto Repair HELPPPPPPPPPPPPPPPPPPPPP Hot Help Archive 9 20/02/2009 01:14 AM


All times are GMT. The time now is 09:29 AM.


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