[solved]nodamage filterscript doesnt work
#1

Код:
#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?
Reply
#2

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

yea i know, but the timer does nothing

if you have some damage it will never repair now



the script does nothing now...
Reply
#4

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
Reply
#5

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

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.
Reply
#7

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.
Reply
#8

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 }
Reply
#9

okeyy thank you it works
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)