SA-MP Forums Archive
[solved]nodamage filterscript doesnt work - 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: [solved]nodamage filterscript doesnt work (/showthread.php?tid=156221)



[solved]nodamage filterscript doesnt work - killertrain - 21.06.2010

Код:
#define FILTERSCRIPT

#include <a_samp>

forward myTimer();

public OnFilterScriptInit()
{
  SetTimer("myTimer", 5000, true);
  return true;
}

public myTimer()
{
  new playerid;
 	RepairVehicle(GetPlayerVehicleID(playerid));
 	GivePlayerMoney(playerid, 500);
  return true;
}
i have made this script to give the cars infinite healt..
it worked until i added the code to give the player 500 money every 5 seconds...

now im trying to get my old script back to work but everything i tryed didnt help...

do you guys have any tips?


Re: nodamage filterscript doesnt work - iggy1 - 21.06.2010

your timer is set to 5 seconds so it will only repair every 5 seconds.


Re: nodamage filterscript doesnt work - killertrain - 21.06.2010

yea i know, but the timer does nothing

if you have some damage it will never repair now



the script does nothing now...


Re: nodamage filterscript doesnt work - iggy1 - 21.06.2010

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

forward myTimer(playerid);//playerid param

public OnFilterScriptInit()
{
  SetTimer("myTimer", 5000, true);
  return true;
}

public myTimer(playerid)
{
  new playerid;
    RepairVehicle(GetPlayerVehicleID(playerid));
    GivePlayerMoney(playerid, 500);
  return true;
}
try that


Re: nodamage filterscript doesnt work - Hiddos - 21.06.2010

pawn Код:
public myTimer()
{
for(new i; i < MAX_PLAYERS; i++)
{
RepairVehicle(GetPlayerVehicleID(playerid));
GivePlayerMoney(playerid,500);
}
return 1;



Re: nodamage filterscript doesnt work - killertrain - 21.06.2010

sorry it doesn't work and i get an error in the compiler :

nodamage.pwn(15) : warning 219: local variable "playerid" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.



Re: nodamage filterscript doesnt work - iggy1 - 21.06.2010

what hiddos said^^
pawn Код:
public myTimer()
{
for(new i; i < MAX_PLAYERS; i++)
{
RepairVehicle(GetPlayerVehicleID(i));
GivePlayerMoney(i,500);
}
return 1;
not sure but think it should be like that.


Re: nodamage filterscript doesnt work - killertrain - 21.06.2010

now i get this error:

nodamage.pwn(22) : error 030: compound statement not closed at the end of file (started at line 16)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.


oops just a }



Re: nodamage filterscript doesnt work - killertrain - 21.06.2010

okeyy thank you it works


Re: [solved]nodamage filterscript doesnt work - Niixie - 21.06.2010

if you dont want to loop it inside the timer, you can use SetTimerEx insted. like this

Код:
OnFilterScriptInit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetTimerEx("myTimer", 5000, true, "d", i);
}
return 1;
}

forward myTimer(playerid);
public myTimer(playerid)
{
RepairVehicle(GetPlayerVehicleID(playerid));
GivePlayerMoney(playerid,500);
return 1;
}
No reason for not looping inside the timer, just so you know that you can do it this way aswell