Timers..
#1

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

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

Ye but how about when i want to call these flare[0] etc. to CreateObject ?
Reply
#4

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

Код:
CreateObject(flares[0]);
....So.. what needs to be changed? :S
Reply
#6

Sorry i still dont get it.
Reply
#7

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]);
    }
}
Reply
#8

Yes, but i want the objects respawned (it goes 10 seconds, then the objects are destroyed, and then created again) In a loop..
Reply
#9

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);
}
Reply
#10

Код:
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]);
Reply
#11

I think it worked with Flares* instead of Flare, No errors
Reply
#12

I left out an 's' on flares sorry, change the destroy line to
pawn Код:
DestroyObject(flares[f]);
Reply
#13

It works now thanks.
Reply


Forum Jump:


Users browsing this thread: