Object respawning timer..
#1

I did some ATM amchines and the code with them a while ago, I've been using an object streamer and had the ATMs in that, so they would respawn once a player is in a certain distance.

The problem is, it isnt working so well, since players punch the machines, others near by complain about it.

So i wanted to make a respawn timer, that would destroy and respawn all the atm machines.

The problem im having is that its spawning them, and spawning them again and again on top of eachother, every minute.

So to test i go and punch th emachines to destroy it, and i see more than one machine.

Sometimes 3 or 4, depending how long i've left the timer tunning before i punch the machine...


Heres my code.

pawn Код:
#define MAX_ATMs 10
Timer OnGameModeInit
pawn Код:
ATMspawn();
SetTimer("ATM_Respawn", 60000, 1);
pawn Код:
new ATM_ID[MAX_ATMS];
new CreatedATMs;

stock ATMspawn()
{
  for (new i = 0; i < MAX_ATMS; i++)
  {
    ATM_ID[i] = CreateStreamedObject(2942, ATMinfo[i][atmX], ATMinfo[i][atmY], ATMinfo[i][atmZ], ATMinfo[i][atmRX], ATMinfo[i][atmRY], ATMinfo[i][atmRZ]);
        CreatedATMs = 1;
    }
}

forward ATM_Respawn();
public ATM_Respawn()
{
  for (new i = 0; i < MAX_ATMS; i++)
    {
        if(CreatedATMs == 1)
      {
        DestroyStreamedObject(ATM_ID[i]);
        CreatedATMs = -1;
        }
        ATM_ID[i] = CreateStreamedObject(2942, ATMinfo[i][atmX], ATMinfo[i][atmY], ATMinfo[i][atmZ], ATMinfo[i][atmRX], ATMinfo[i][atmRY], ATMinfo[i][atmRZ]);
        CreatedATMs = 0;
    }
    return 1;
}
Reply
#2


pawn Код:
#define MAX_ATMs 10
Timer OnGameModeInit
pawn Код:
ATMspawn();
SetTimer("ATM_Respawn", 60000, 1);
pawn Код:
new ATM_ID[MAX_ATMS];
new CreatedATMs;

stock ATMspawn()
{
  for (new i = 0; i < MAX_ATMS; i++)
  {
    ATM_ID[i] = CreateStreamedObject(2942, ATMinfo[i][atmX], ATMinfo[i][atmY], ATMinfo[i][atmZ], ATMinfo[i][atmRX], ATMinfo[i][atmRY], ATMinfo[i][atmRZ]);
        CreatedATMs = 1;
    }
}

forward ATM_Respawn();
public ATM_Respawn()
{
  for (new i = 0; i < MAX_ATMS; i++)
    {
        if(CreatedATMs == 1)
      {
        DestroyStreamedObject(ATM_ID[i]);
        CreatedATMs = -1;
        }
        ATM_ID[i] = CreateStreamedObject(2942, ATMinfo[i][atmX], ATMinfo[i][atmY], ATMinfo[i][atmZ], ATMinfo[i][atmRX], ATMinfo[i][atmRY], ATMinfo[i][atmRZ]);
        CreatedATMs = 0;
    }
    return 1;
}
[/quote]
at the define you have MAX_ATMs
try MAX_ATMS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)