[SOLVED] Respawning vehicles
#1

I was spawning some vehicles, adding them to a file and at the end I wanted to respawn them aka removing. Never tried it out so I don't know if it ever worked. With spawned vehicles or without spawned vehicles, it keeps crashing.

Script:
pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsVehicleOccupied(i) == 0)
{
SetVehicleToRespawn(i);
}
}
}
Reply
#2

!bump
Reply
#3

You need a respawn command?
Reply
#4

.. got no eyes to read something before posting?
Reply
#5

Well I just typed this (didn't post ughn)

Try to debug by typing prints along the function and see what one it stops on.

I suspect the crash is in one of the functions you are calling and not the one shown.
Reply
#6

pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
  for(new i; i<MAX_VEHICLES; i++)
  {
    if(!IsVehicleOccupied(i))
    {
      SetVehicleToRespawn(i);
    }
  }
  return 1;
}
You should return 1; at the end. Also, you don't need to state that "i=0" since it automatically is equal to 0 when you create it (new).
Reply
#7

this is called like 1000 times more, but I can't post it here..
pawn Код:
[19:58:57] nr. 1 is called
[19:58:58] nr. 2 is called
[19:58:58] nr. 3 is called
[19:58:58] nr. 4 is called
pawn Код:
Exception At Address: 0x00484850



Registers:

EAX: 0x205D215B EBX: 0x014D1E73 ECX: 0x7FFFFFFE EDX: 0x0012F229

ESI: 0x0012EE60 EDI: 0x0012F654 EBP: 0x0012EEAC ESP: 0x0012EE20

EFLAGS: 0x00010202



Stack:

+0000: 0x0012F5F8  0x0012F1F8  0x014D1E78  0x0012F66C

+0010: 0x00000000  0x00000000  0x0012EE28  0x00000007

+0020: 0x00000000  0x00483E4C  0x00000000  0x00000000

+0030: 0x00000000  0x00000000  0x00000000  0x4B4F6972

+0040: 0x00000032  0x00000000  0x205D215B  0xFFFFFFFF

+0050: 0x00000000  0x00006B5D  0x00000000  0x00000001

+0060: 0x00000000  0x00000000  0x00000000  0x00006B5D

+0070: 0x00000000  0x0012EEEC  0x0048A6C4  0x00000068

+0080: 0x00000000  0x00000000  0x00000002  0x004BB980

+0090: 0x0048CB63  0x009B1FA0  0x0048A792  0x00000003

+00A0: 0x0048A7AF  0x00000000  0x004ABDE8  0x00000003

+00B0: 0x00006B5D  0x0012EEC4  0x0012EEC8  0x0012F1C8

+00C0: 0x00483E4C  0x004A1170  0xFFFFFFFF  0x0048A7AF

+00D0: 0x0048580D  0x00000003  0x00000000  0x00000002

+00E0: 0x004ABDE8  0x0012EF70  0x00CA0488  0x0012EFBC

+00F0: 0x004842BE  0x0000005B  0xFFFFFFCB  0x00484316

+0100: 0xFFFFFFCB  0x00000000  0x00484AA9  0x0048457F

+0110: 0x009B75B0  0x004ABDE8  0x00484AF8  0x00C9EFB8

+0120: 0x00450083  0x00000000  0x0012EF7C  0x00000000

+0130: 0x00000000  0x00000021  0x00000000  0x00000000
check made with:
pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
print("nr. 1 is called");
  for(new i; i<MAX_VEHICLES; i++)
  {
  print("nr. 2 is called");
    if(!IsVehicleOccupied(i))
    {
    print("nr. 3 is called");
      SetVehicleToRespawn(i);
    print("nr. 4 is called");
    }
  }
  return 1;
}
Quote:
Originally Posted by -The_Badger-
pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
  for(new i; i<MAX_VEHICLES; i++)
  {
    if(!IsVehicleOccupied(i))
    {
      SetVehicleToRespawn(i);
    }
  }
  return 1;
}
You should return 1; at the end. Also, you don't need to state that "i=0" since it automatically is equal to 0 when you create it (new).
Thank you for your reply
Reply
#8

Try
pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
    for(new i = 1; i<MAX_VEHICLES; i++)
    {
        if(!IsVehicleOccupied(i))
        {
            if(GetVehicleModel(i))
            {
                SetVehicleToRespawn(i);
            }
        }
    }
}
so you wont respawn invalid ids
Reply
#9

Try this debug:

pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
  for(new i; i<MAX_VEHICLES; i++)
  {
    printf("nr. %i is called", i);
    if(!IsVehicleOccupied(i))
    {
      SetVehicleToRespawn(i);
    }
  }
  return 1;
}
Reply
#10

Quote:
Originally Posted by dice7
Try
pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
    for(new i = 1; i<MAX_VEHICLES; i++)
    {
        if(!IsVehicleOccupied(i))
        {
            if(GetVehicleModel(i))
            {
                SetVehicleToRespawn(i);
            }
        }
    }
}
so you wont respawn invalid ids
Thank you for your reply, but still the same.
Quote:
Originally Posted by MadeMan
Try this debug:

pawn Код:
forward RespawnEmptyCars();
public RespawnEmptyCars()
{
  for(new i; i<MAX_VEHICLES; i++)
  {
    printf("nr. %i is called", i);
    if(!IsVehicleOccupied(i))
    {
      SetVehicleToRespawn(i);
    }
  }
  return 1;
}
Thank you for your reply, now the serverlog says it has called from 1 to 2000 cars

EDIT: 1 to 18
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)