Problem with vehicle respawning? or what
#1

Hey,

I have made this little gangwar minigame. You enter it by typing /gangwars.
It has cars, objects(set only in world2).

Theres a little problem that I can't seem to figure out.
The problem is (sometimes) when I enter (/gangwars) the cars are like this:

http://imageshack.us/photo/my-images/811/samp284pa.png/

This doesn't always happen sometimes I join and everything they are like this:

http://imageshack.us/photo/my-images/828/samp285o.png/

Thats what they are supposed to look like.
And as I mentioned above if you enter it's (sometimes) fine but then if you type /exit and re-join it again , /gangwars. They are like the first picture I showed.

This is really annoying and I can't seem to figure out what it's wrong, I only thing I know is, maybe it's related to vehicle respawning time.

I will give you some more info , including codes:
pawn Код:
new gcar1 = AddStaticVehicle(492,2481.76928711,-1655.14123535,13.23549938,89.00000000,86,86); //Greenwood
    new gcar2 = AddStaticVehicle(492,2490.54248047,-1655.33972168,13.23549938,88.99475098,86,86); //Greenwood
    new gcar3 = AddStaticVehicle(492,2504.81640625,-1651.08117676,13.23549938,142.99475098,86,86); //Greenwood
    new gcar4 = AddStaticVehicle(492,2472.94335938,-1655.05871582,13.23549938,88.99475098,86,86); //Greenwood
    new gcar5 = AddStaticVehicle(487,2503.71435547,-1668.32397461,13.62807465,0.00000000,86,44); //Maverick
    new gcar6 = AddStaticVehicle(413,2473.96093750,-1695.36181641,13.66538715,0.00000000,86,1); //Pony
    new gcar7 = AddStaticVehicle(492,2483.19116211,-1686.29833984,13.23549938,88.99475098,86,86); //Greenwood
   
    SetVehicleVirtualWorld(gcar1,2);
    SetVehicleVirtualWorld(gcar2,2);
    SetVehicleVirtualWorld(gcar3,2);
    SetVehicleVirtualWorld(gcar4,2);
    SetVehicleVirtualWorld(gcar5,2);
    SetVehicleVirtualWorld(gcar6,2);
    SetVehicleVirtualWorld(gcar7,2);
Thats the cars code and they are set in world 2 like I said.
And this is the exit.
pawn Код:
if(strcmp(cmdtext, "/exit", true) == 0)
    {
        if(InWar[playerid] == 1 || InGangWar[playerid] == 1)
        {
            if(InWar[playerid] == 1)
            {
               InWar[playerid] = 0;
               SendClientMessage(playerid,COLOR_YELLOW,"You have left the deathmatch");
               SetPlayerWorldBounds(playerid,20000.0000, -20000.0000, 20000.0000, -20000.0000);
               SpawnPlayer(playerid);
               SetCameraBehindPlayer(playerid);
            }
            else if(InGangWar[playerid] == 1)
            {
               InGangWar[playerid] = 0;
               SendClientMessage(playerid,COLOR_YELLOW,"You have left the minigame");
               SetPlayerVirtualWorld(playerid,0);
               SetPlayerInterior(playerid,0);
               SpawnPlayer(playerid);
               SetCameraBehindPlayer(playerid);
           
            }

        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You are not in a minigame or deathmatch.");
        }
        return 1;
    }
Other info:

I have objects at the same place and vehicles, in world 0.

Anyone know the problem? If you want more information just ask me , including code. I don't mind I would just like this to be fixed.

Thanks.
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
Most likely the cars are spawning faster than the world around them when you teleport to that area (I'm guessing there is a "SetPlayerPos", or other location modifying code, somewhere). If this is the case they will fall through the ground and respawn on the closest "node path", i.e. defined piece of road, in grove street. To combat this there are a number of methods, one would be move the player there and change their virtual world a few moments later to ensure the world spawns before the vehicles.
pawn Код:
if(listitem == 0)
             {
             
                gTeam[playerid] = TEAM_GROVE;
                InGangWar[playerid] = 1;
                SetPlayerColor(playerid,TEAM_COLOR_GROVE);
                SetPlayerVirtualWorld(playerid,2);
                SendClientMessage(playerid,COLOR_GREEN,"You have selected The Grove!");
                SendClientMessage(playerid,COLOR_WHITE,"Objective: Kill other gangs");
                SendClientMessage(playerid,COLOR_WHITE,"finds drugs, rob banks or just cruise with your homies");
                SendClientMessage(playerid,COLOR_YELLOW,"Use /gcommands for all commands.");
                switch(random(4))
                {
                    case 0:
                    {
                       SetPlayerPos(playerid,2496.4500,-1708.5156,1014.7422);
                       SetPlayerInterior(playerid,3);
                    }
                    case 1:
                    {
                       SetPlayerPos(playerid,2492.5818,-1700.5641,1014.7661);
                       SetPlayerInterior(playerid,3);
                    }
                    case 2:
                    {
                       SetPlayerPos(playerid,2492.5183,-1702.5121,1018.3438);
                       SetPlayerInterior(playerid,3);
                       
                    }
                    case 3:
                    {
                       SetPlayerPos(playerid,2497.7595,-1678.0848,13.3507);
                       
                    }


                }
                switch(random(3))
                {
                    case 0: SetPlayerSkin(playerid,105);
                    case 1: SetPlayerSkin(playerid,106);
                    case 2: SetPlayerSkin(playerid,107);
                }

             
             }
Perhaps?
I tried moving
pawn Код:
SetPlayerVirtualWorld(playerid,2);
Under the second to last bracket( a little later).
But the problem is still occurring.

Anymore methods?

Thanks
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
That is not "later" (well, it is, but microseconds later) - that's just not enough time. I'm talking seconds, milliseconds at best.
Well a timer?
Trouble is i'd need alot of them for each of my teams.

Also is there any other solutions ? /:

Change the vehicle "spawn" time ?
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
Why? Just add a parameter to the timer.
I will be honest and say im not sure what you mean. or how I would do this.
I don't want to use lots of timers as I have different teams.
And is there a different way ? You said there is more

Can you tell me them?

Thanks


Below: If you don't mind can you tell me the other ways ? I would like to know.
Reply
#5

Well I tried this:

pawn Код:
if(dialogid == 13)
    {
         if(response)
         {
         
             if(listitem == 0)
             {
             
                gTeam[playerid] = TEAM_GROVE;
                InGangWar[playerid] = 1;
                SetPlayerColor(playerid,TEAM_COLOR_GROVE);
                SendClientMessage(playerid,COLOR_GREEN,"You have selected The Grove!");
                SendClientMessage(playerid,COLOR_WHITE,"Objective: Kill other gangs");
                SendClientMessage(playerid,COLOR_WHITE,"finds drugs, rob banks or just cruise with your homies");
                SendClientMessage(playerid,COLOR_YELLOW,"Use /gcommands for all commands.");
                switch(random(4))
                {
                    case 0:
                    {
                       SetPlayerPos(playerid,2496.4500,-1708.5156,1014.7422);
                       SetPlayerInterior(playerid,3);
                    }
                    case 1:
                    {
                       SetPlayerPos(playerid,2492.5818,-1700.5641,1014.7661);
                       SetPlayerInterior(playerid,3);
                    }
                    case 2:
                    {
                       SetPlayerPos(playerid,2492.5183,-1702.5121,1018.3438);
                       SetPlayerInterior(playerid,3);
                       
                    }
                    case 3:
                    {
                       SetPlayerPos(playerid,2497.7595,-1678.0848,13.3507);
                       
                    }


                }
                switch(random(3))
                {
                    case 0: SetPlayerSkin(playerid,105);
                    case 1: SetPlayerSkin(playerid,106);
                    case 2: SetPlayerSkin(playerid,107);
                }

             
             }
             if(listitem == 1)
             {
                gTeam[playerid] = TEAM_BALLAS;
                InGangWar[playerid] = 1;
                SetPlayerColor(playerid,TEAM_COLOR_BALLAS);
                SendClientMessage(playerid,COLOR_PURPLE,"You have selected The Ballas!");
                SendClientMessage(playerid,COLOR_WHITE,"Objective: Kill other gangs");
                SendClientMessage(playerid,COLOR_WHITE,"finds drugs, rob banks or just cruise with your homies");
                SendClientMessage(playerid,COLOR_YELLOW,"Use /gcommands for all commands.");
             
             
             
             }
             if(listitem == 2)
             {
                gTeam[playerid] = TEAM_VAGOS;
                InGangWar[playerid] = 1;
                SetPlayerColor(playerid,TEAM_COLOR_VAGOS);
                SendClientMessage(playerid,COLOR_YELLOW,"You have selected The Vagos!");
                SendClientMessage(playerid,COLOR_WHITE,"Objective: Kill other gangs");
                SendClientMessage(playerid,COLOR_WHITE,"finds drugs, rob banks or just cruise with your homies");
                SendClientMessage(playerid,COLOR_YELLOW,"Use /gcommands for all commands.");



             }
             if(listitem == 3)
             {
                gTeam[playerid] = TEAM_POLICE;
                InGangWar[playerid] = 1;
                SetPlayerColor(playerid,TEAM_COLOR_POLICE);
                SendClientMessage(playerid,COLOR_BLUE,"You have selected The Poilce!");
                SendClientMessage(playerid,COLOR_WHITE,"Objective: Bust /wanted gangs.");
                SendClientMessage(playerid,COLOR_WHITE,"or just cruise around looking for trouble.");
                SendClientMessage(playerid,COLOR_YELLOW,"Use /gcommands for all commands.");


             }
             SetTimerEx("WorldSetDelay",3000,0,"d",playerid);
         
         
         }
   
   
   
   
    }
    return 1;
}


forward WorldSetDelay(playerid);
public WorldSetDelay(playerid)
{

    SetPlayerVirtualWorld(playerid,2);
    SendClientMessage(playerid,COLOR_YELLOW,"Success");

}
You can see I added the timer. But it's still not working.
so I thought to myself about what else could be a problem.

And yes - I have like 3 spawns that are in a interior(grove street house) and when I come out (when the timer loaded "success" I see the vehicles fall into place, the bad place. Not my positions.

So yeah, I don't know if the interior can be a problem?

EDIT:

I did some tests:

I removed 3 of my spawns and left the 1 that spawns outside.
I tried it again and then (not in interior this time)

I spawned outside and the normal vehicle positions loaded.
Then I removed the timer and tried again , it worked! - so that is/was not needed anymore.

So I think this is the problem , the interior. Grove street house.
I will just create spawns outside if thats the case.

But I would like some answers from you ****** , or some other advanced scripter.
about why this was happening(with the interior ) or even better, if I can bypass this.

I would like to thank everyone who has helped on this thread and especially ****** for huge help.
And yeah , I would like someone to tell me why.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Did you correctly link the vehicle to an interiour?
Erm, i didn't quite understand.

I spawned in an interior then went outside and the cars were in world 2.
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Oh, wait, YOU, spawn in the interior? In that case you will still have the problem I said when you go outside as the map will still take time to load.
No, now all my spawns are outside and everything works fine.
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)