/stick & /unstick
#1

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.
Reply
#2

Just delete the object you created using DestroyObject(objectid);
Reply
#3

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
Reply
#4

I know those functions -.-, and should I destroy and recreate the object?

EDIT: Fixed. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)