Timers.. -
RedFusion - 20.10.2010
I forgot how to use new...
here's the code
Код:
new flares;
forward flaretimer();
public OnFilterScriptInit()
{
...
...
...
flares = CreateObject(354,2050,1538,28,0,0,0), CreateObject(354,2056,1541,30,0,0,0), CreateObject(354,2056,1530,35,0,0,0), CreateObject(354,2049,1529,38,0,0,0);//Here... This function.
SetTimer("flaretimer",10000,true);
return 1;
}
public flaretimer()
{
DestroyObject(flares);
flares; // Here is the problem, i want to use that "Flares" Somehow, to re-create the 4 flares..
}
Re: Timers.. -
iggy1 - 20.10.2010
You can only assign one value to an integer variable do it like this.
pawn Код:
new flares[3];
flares[0] = CreateObject(354,2050,1538,28,0,0,0);
flares[1] = CreateObject(354,2056,1541,30,0,0,0);
flares[2] = CreateObject(354,2056,1530,35,0,0,0);
//and so on
Re: Timers.. -
RedFusion - 20.10.2010
Ye but how about when i want to call these flare[0] etc. to CreateObject ?
Re: Timers.. -
iggy1 - 20.10.2010
You must use CreateObject to create an object you can't create objects with variables alone. All you are doing with variables is storing the objects internal id into them (not the modlid). So you can manipulate the objects ie, DestroyObject.
Re: Timers.. -
RedFusion - 20.10.2010
Код:
CreateObject(flares[0]);
....So.. what needs to be changed? :S
Re: Timers.. -
RedFusion - 20.10.2010
Sorry i still dont get it.
Re: Timers.. -
iggy1 - 20.10.2010
Give this a try,
pawn Код:
new flares[3];//at top of script with other global variables (under includes and defines prefferably)
public OnFilterScriptInit()
{
flares[0] = CreateObject(354,2050,1538,28,0,0,0);
flares[1] = CreateObject(354,2056,1541,30,0,0,0);
flares[3] = CreateObject(354,2056,1530,35,0,0,0);
flares[4] = CreateObject(354,2049,1529,38,0,0,0);//Here... This function.
SetTimer("flaretimer",10000,true);
return 1;
}
public flaretimer()
{
for(new f; f < 4; f++)
{
DestroyObject(flare[f]);
}
}
Re: Timers.. -
RedFusion - 20.10.2010
Yes, but i want the objects respawned (it goes 10 seconds, then the objects are destroyed, and then created again) In a loop..
Re: Timers.. -
iggy1 - 20.10.2010
Change the timer to
pawn Код:
public flaretimer()
{
for(new f; f < 4; f++)
{
DestroyObject(flare[f]);
}
flares[0] = CreateObject(354,2050,1538,28,0,0,0);
flares[1] = CreateObject(354,2056,1541,30,0,0,0);
flares[3] = CreateObject(354,2056,1530,35,0,0,0);
flares[4] = CreateObject(354,2049,1529,38,0,0,0);
SetTimer("flaretimer",10000,true);
}
Re: Timers.. -
RedFusion - 20.10.2010
Код:
C:\server\filterscripts\lol.pwn(85) : error 017: undefined symbol "flare"
C:\server\filterscripts\lol.pwn(85) : warning 215: expression has no effect
C:\server\filterscripts\lol.pwn(85) : error 001: expected token: ";", but found "]"
C:\server\filterscripts\lol.pwn(85) : error 029: invalid expression, assumed zero
C:\server\filterscripts\lol.pwn(85) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664
Код:
85 DestroyObject(flare[f]);
Re: Timers.. -
RedFusion - 20.10.2010
I think it worked with Flares* instead of Flare, No errors
Re: Timers.. -
iggy1 - 20.10.2010
I left out an 's' on flares sorry, change the destroy line to
pawn Код:
DestroyObject(flares[f]);
Re: Timers.. -
RedFusion - 20.10.2010
It works now thanks.