Controle SetPlayerPos? - 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: Controle SetPlayerPos? (
/showthread.php?tid=554929)
Controle SetPlayerPos? -
CrazyChoco - 05.01.2015
Hello,
I am running into a problem when I'm using checkpoints.
I am not getting a pawno error, everything compiles fine.
What im basically trying to do is, that I want to make two cp. Player run into one cp, and then he gets teleported to the next cp's location, but instead of getting spawned back to cp1, he should stay in cp2 and if he runs into cp 2 he should go to cp 1 if you get it?
My code is basically:
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == h[1])//Enter
{
SetPlayerPos(playerid, 238.727615, 138.634033, 1003.023437);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 3);
}
if(checkpointid == h[2]) //Exit
{
SetPlayerPos(playerid, 2287.032958, 2432.367187, 10.820312);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 0);
}
return 1;
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
if(checkpointid == h[1])//Enter
{
}
if(checkpointid == h[2]) //Exit
{
}
return 1;
}
As you can see this will just go as a loop, but I want to controle it, as i tried to describe above.
Re: Controle SetPlayerPos? -
Sawalha - 05.01.2015
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == h[1])//Enter
{
SetPlayerPos(playerid, 238.727615, 138.634033, 1003.023437);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 3);
}
else if(checkpointid == h[2]) //Exit
{
SetPlayerPos(playerid, 2287.032958, 2432.367187, 10.820312);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 0);
}
return 1;
}
try
Re: Controle SetPlayerPos? -
CrazyChoco - 05.01.2015
It doesn't work, it will still put me in a kinda "loop" where i spawn between the two checkpoints. I imagined I could use variables, but I just can't solve the math when using variables.
Re: Controle SetPlayerPos? -
Larceny - 05.01.2015
You can set a timer:
The player can only enter another CP after 5 seconds he entered one. So the player will have time to leave the checkpoint without entering again.
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(GetPVarInt(playerid, "EnterCPTick") > GetTickCount())
return 1;
if(checkpointid == h[1])//Enter
{
SetPlayerPos(playerid, 238.727615, 138.634033, 1003.023437);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 3);
}
else if(checkpointid == h[2]) //Exit
{
SetPlayerPos(playerid, 2287.032958, 2432.367187, 10.820312);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 0);
}
SetPVarInt(playerid, "EnterCPTick", GetTickCount() + 5000);
return 1;
}