SetPlayerPos not always working
#1

Hi, I have a deathmatch system and I have a strange problem when the player's position is not always getting set, dont know why.

I use it like this:
pawn Код:
SetTimerEx("VDMHydraSpawn", 750, 0, "i", playerid);
I used it first with "VDMHydraSpawn(playerid); but I thought that would bug it so I changed it to to timer but still bugging. Heres the code itself
pawn Код:
public VDMHydraSpawn(playerid)
{
    if(IsInVDM[playerid] == 1)
    {
        Hydraspawn = random(10);
        if (Hydraspawn == 0)
        {
            SetPlayerPos(playerid,307.7739,1805.6658,18.5583);
            SetPlayerFacingAngle(playerid,2);
            SetCameraBehindPlayer(playerid);
        }
        if (Hydraspawn == 1)
        {
            SetPlayerPos(playerid,309.0186,2054.4512,18.5585);
            SetPlayerFacingAngle(playerid, 179);
            SetCameraBehindPlayer(playerid);
                }
                //more random spawns here, probably not necessary to see here
        SetPlayerWorldBounds(playerid, 782.4177, -502.1487, 2510.743, 1109.398);
        SetTimerEx("VDMSpawnHydra", 750, 0, "i", playerid);
    }
}
Reply
#2

How many random spawns do you have?
Reply
#3

10 (message too short)
Reply
#4

Change
pawn Код:
random(10);
to
pawn Код:
random(9);
- remember, computers start at 0. It doesn't work each time because if 10 was selected there is no definition of it, so it panics and doesn't know what to do.
Reply
#5

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Change
pawn Код:
random(10);
to
pawn Код:
random(9);
- remember, computers start at 0. It doesn't work each time because if 10 was selected there is no definition of it, so it panics and doesn't know what to do.
That's what he did, there's 10 digits, 0 = 1, 1 = 2..There would still be 10 numbers


Maybe this would work better;
pawn Код:
new Float:HydraSpawns[10][4] = {
    {307.7739,1805.6658,18.5583,2},
    {309.0186,2054.4512,18.5585,179},
    //The rest of them
}

public OnPlayerSpawn(playerid)
{
    if(IsInVDM[playerid] == 1)
    {
        new rand = random(sizeof(HydraSpawns));
        SetPlayerPos(playerid, HydraSpawns[rand][0], HydraSpawns[rand][1], HydraSpawns[rand][2]);
        SetPlayerFacingAngle(playerid, HydraSpawns[rand][3]);
        SetCameraBehindPlayer(playerid);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)