Question
#1

Hi,

I made this /stick & /unstick command to stick and unstick an object to a player. The problem is, when using /unstick the object respawns at the place I originally created it instead of the player's position.

Код:
	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!");

    GetObjectPos(Object, Pxx, Pyy, Pzz);
		DestroyObject(Object);
		oX = Pxx - 2.0;
		oY = Pyy - 2.0;
		oZ = Pzz - 0.0;
		Object = CreateObject(newobj, oX, oY, oZ, xR, yR, zR);
	  StickedToObject[playerid] = 0;
	  SendClientMessage(playerid, COLOR_GREEN, "* You have been released from your object!");
		SetObjectPos(Object, oX, oY, oZ);
		SetObjectRot(Object, xR, yR, zR);
	  #pragma unused params
	  return 1;
	}
Don't blame me for the intendation :+
Reply
#2

Anyone?
Reply
#3

Simply put I don't think you can use GetObjectPos, you have to use GetPlayerPos and work it out from there.
Reply
#4

Thanks for your reply, I'll try that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)