SetPlayerPos not always working - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SetPlayerPos not always working (
/showthread.php?tid=312259)
SetPlayerPos not always working -
McCarthy - 20.01.2012
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);
}
}
Re: SetPlayerPos not always working -
Dokins - 20.01.2012
How many random spawns do you have?
Re: SetPlayerPos not always working -
McCarthy - 20.01.2012
10 (message too short)
Re: SetPlayerPos not always working -
Dokins - 20.01.2012
Change
to
- 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.
Re: SetPlayerPos not always working -
[ABK]Antonio - 20.01.2012
Quote:
Originally Posted by Dokins
Change to - 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);
}
}