SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 15/03/2009, 12:35 PM   #1
Outbreak
Huge Clucker
 
Join Date: Dec 2008
Posts: 303
Reputation: 3
Default Object respawning timer..

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 Code:
#define MAX_ATMs 10

Timer OnGameModeInit
pawn Code:
ATMspawn();
SetTimer("ATM_Respawn", 60000, 1);

pawn Code:
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;
}
Outbreak is offline  
Old 11/05/2009, 05:07 PM   #2
matrix_smq
Little Clucker
 
Join Date: Feb 2009
Posts: 24
Reputation: 0
Default Re: Object respawning timer..


pawn Code:
#define MAX_ATMs 10

Timer OnGameModeInit
pawn Code:
ATMspawn();
SetTimer("ATM_Respawn", 60000, 1);

pawn Code:
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
matrix_smq is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I put a timer on respawning a vehicle ||123|| Help Archive 10 16/06/2010 12:12 AM
Create/Destroy object timer reallifescript Help Archive 5 01/06/2010 10:08 PM
Timer on a object, i need help Perker12345 Help Archive 0 17/02/2010 03:03 PM


All times are GMT. The time now is 11:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.