[Tutorial] How to fix onplayerclickmap function - 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)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to fix onplayerclickmap function (
/showthread.php?tid=594096)
How to fix onplayerclickmap function -
leo9 - 13.11.2015
This is how to fix the problem when the position is so far from player and the z coordinate is 0,without using any plugins.
Код:
new bool:ClickedOnMap[MAX_PLAYERS] = false;
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
SetPlayerPos(playerid, fX, fY, 550);
GameTextForPlayer(playerid,"Teleporting",1000,4);
ClickedOnMap[playerid] = true;
return 1;
}
public OnPlayerUpdate(playerid)
{
if(ClickedOnMap[playerid] == true)
{
new Float:p[3];
GetPlayerPos(playerid,p[0],p[1],p[2]);
SetPlayerPosFindZ(playerid,p[0],p[1],p[2]);
KillTimer(TelTimer[playerid]);
TogglePlayerControllable(playerid, true);
ClickedOnMap[playerid] = false;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
ClickedOnMap[playerid] = false;
}
I hope its usefull
Re: How to fix onplayerclickmap function -
Kevln - 13.11.2015
SetPlayerPosFindZ isn't even a valid function.
You can make this in a way better way.
Re: How to fix onplayerclickmap function -
Gammix - 14.11.2015
Quote:
Originally Posted by Kevln
SetPlayerPosFindZ isn't even a valid function.
You can make this in a way better way.
|
Its is valid sir. (from a_players.inc)
Quote:
native SetPlayerPos(playerid, Float:x, Float:y, Float:z);
native SetPlayerPosFindZ(playerid, Float:x, Float:y, Float:z);
native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z);
|
OT: Just use SetPlayerPosFindZ under the callback, instead of making it complex like your code.
Re: How to fix onplayerclickmap function -
Kar - 14.11.2015
Or just use mapandreas.
Re: How to fix onplayerclickmap function -
kristo - 14.11.2015
Quote:
Originally Posted by Gammix
OT: Just use SetPlayerPosFindZ under the callback, instead of making it complex like your code.
|
https://sampwiki.blast.hk/wiki/SetPlayerPosFindZ
Quote:
Originally Posted by wiki
This function does not work if the new coordinates are far away from where the player currently is. The Z height will be 0, which will likely put them underground.
|
He uses SetPlayerPos a few milliseconds before SetPlayerPosFindZ to make this work properly.
Quote:
Originally Posted by Kar
Or just use mapandreas.
|
SetPlayerPosFindZ has a pro over MapAndreas:
Quote:
Originally Posted by wiki
This sets the players position then adjusts the players z-coordinate to the nearest solid ground under the position.
|
While MapAndreas always gives the position of the ground.
Re: How to fix onplayerclickmap function -
Gammix - 14.11.2015
Quote:
Originally Posted by kvann
|
Use SetPlayerPos first and SetPlayerPosFindZ after that. I think that would work.
Re: How to fix onplayerclickmap function -
leo9 - 14.11.2015
Quote:
Originally Posted by Gammix
Use SetPlayerPos first and SetPlayerPosFindZ after that. I think that would work.
|
I tried that but it doesn't give the right z coordinates