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


Messages In This Thread
Question - by GTA_Rules - 24.05.2009, 17:37
Re: Question - by GTA_Rules - 24.05.2009, 19:42
Re: Question - by Weirdosport - 24.05.2009, 19:42
Re: Question - by GTA_Rules - 24.05.2009, 19:49

Forum Jump:


Users browsing this thread: 4 Guest(s)