/stick & /unstick - 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: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /stick & /unstick (
/showthread.php?tid=78931)
/stick & /unstick -
GTA_Rules - 24.05.2009
Hi,
Okay, I'm not really stuck with a command, but I'm wondering how I could do this better. I'm using AttachPlayerToObject or whatever it's called to make a /stick command. Now when unsticking it, SpawnPlayer(playerid) and then setting the player's pos to that location fails as he still has the object attached to him.
Only thing working is SetPlayerHealth(playerid, 0 );, but when using that animation the object moves a little bit forwards (due to the player falling down).
Commands:
Код:
dcmd_stick(playerid, params[])
{
if(EditingObject[playerid] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You aren't editing any objects!");
if(StickedToObject[playerid] == 1) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are already sticked to the object!");
StickedToObject[playerid] = 1;
AttachObjectToPlayer( Object, playerid, 2.0, 2.0, 0.0, 0, 1.5, 2 );
#pragma unused params
return 1;
}
dcmd_unstick(playerid, params[])
{
new Float:Pxx, Float:Pyy, Float:Pzz;
if(EditingObject[playerid] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You aren't editing any objects!");
if(StickedToObject[playerid] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You aren't sticked to an object!");
StickedToObject[playerid] = 0;
SendClientMessage(playerid, COLOR_GREEN, "* You have been released from your object!");
AttachObjectToPlayer( Object, INVALID_PLAYER_ID, 2.0, 2.0, 0.0, 0, 1.5, 2 );
GetPlayerPos(playerid, Pxx, Pyy, Pzz);
GetObjectRot(playerid, xR, yR, zR);
oX = Pxx - 0.000;
oY = Pyy - 2.000;
oZ = Pzz - 0.001;
SetObjectPos(Object, oX, oY, oZ);
SetObjectRot(Object, xR, yR, zR);
#pragma unused params
return 1;
}
Okay then I tried using INVALID_PLAYER_ID, but that didn't work either, so any suggestions?
Thanks.
Re: /stick & /unstick -
Grim_ - 24.05.2009
Just delete the object you created using DestroyObject(objectid);
Re: /stick & /unstick -
samgreen - 24.05.2009
Yes but it's more than that. You should take a look at the documentation.
Bookmark this link. Make it your best friend! Read it for fun and pleasure!
https://sampwiki.blast.hk/wiki/Category:Scripting_Functions]
https://sampwiki.blast.hk/wiki/Category:Scripting_Functions
Re [FIXED]: /stick & /unstick -
GTA_Rules - 24.05.2009
I know those functions -.-, and should I destroy and recreate the object?
EDIT: Fixed. Thanks.