Problem with in-game objects
#1

What is wrong? Happening nothing when I click on object.

Код:
new bool:IsEditingObject[MAX_PLAYERS];
new object;

public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	if(objectid == object)
	{
		SetPVarInt(playerid, "objectid", objectid);

		new Float:oldX, Float:oldY, Float:oldZ,
			Float:oldRotX, Float:oldRotY, Float:oldRotZ;
		GetObjectPos(objectid, oldX, oldY, oldZ);
		GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
		if(!playerobject) // If this is a global object, move it for other players
		{
		    if(!IsValidObject(objectid)) return;
		    MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
		}

		IsEditingObject[playerid] = true;

		if(response == EDIT_RESPONSE_FINAL)
		{
		    IsEditingObject[playerid] = false;
			// The player clicked on the save icon
			// Do anything here to save the updated object position (and rotation)
		}

		if(response == EDIT_RESPONSE_CANCEL)
		{
		    IsEditingObject[playerid] = false;
			//The player cancelled, so put the object back to it's old position
			if(!playerobject) //Object is not a playerobject
			{
				SetObjectPos(objectid, oldX, oldY, oldZ);
				SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
			}
			else
			{
				SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
				SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
			}
		}
	}
}

public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
{
	if(objectid == object)
	{
	    if(type == SELECT_OBJECT_GLOBAL_OBJECT)
	    {
			EditObject(playerid, objectid);
		}
	    else
	    {
	   		EditPlayerObject(playerid, objectid);
	    }
    }
    return 1;
}

CMD:mc(playerid, params[])
{
	new objectid;
	new worldid = GetPlayerVirtualWorld(playerid);
	new Float:x, Float:y, Float:z;
	new Float:x2, Float:y2;
	GetPlayerPos(playerid, x, y, z);
	GetXYInFrontOfPlayer(playerid, x2, y2, 3);
	
    if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /mc [modelid]");
    if(objectid > 19901 || objectid < 615)
    {
        return SendClientMessage(playerid, COLOR_GREY,"Error: Incorret modelid");
    }
    else
    {
        object = CreateDynamicObject(objectid, x2, y2, z, 0.0, 0.0, 0.0, worldid, -1, -1, 200.0, 0.0);
        EditObject(playerid, object);
    }
	return 1;
}

CMD:msel(playerid, params[])
{
    SelectObject(playerid);
	return 1;
}

CMD:mdel(playerid, params[])
{
	if(IsEditingObject[playerid] == true)
	{
        DestroyObject(GetPVarInt(playerid, "objectid"));
	}
	return 1;
}
Reply
#2

Doesn't work with the Streamer plugin, something is messed up, and when using the OnPlayerEditDynamicObject, OnPlayerEditObject gets called 2x.
Reply
#3

I cannot do that without much errors, damn it. Anyone can fix that for correct work?
Reply
#4

refresh, anyone
Reply
#5

Okay here's what's the problem, if you're using streamer to create a dynamic object you must use streamer natives to edit it. (You can not edit it with SAMP EditObject)
e.g.
Код:
native EditDynamicObject(playerid, objectid);
forward OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
Reply
#6

Now:
Код:
error 055: start of function body without function header
error 010: invalid function or declaration
error 021: symbol already defined: "GetObjectPos"
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 054: unmatched closing brace ("}")
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 010: invalid function or declaration
error 025: function heading differs from prototype
error 017: undefined symbol "SelectDynamicObject"
warning 203: symbol is never used: "oldRotX"
warning 203: symbol is never used: "oldRotY"
warning 203: symbol is never used: "oldRotZ"
warning 203: symbol is never used: "oldX"
warning 203: symbol is never used: "oldY"
warning 203: symbol is never used: "oldZ"
Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
{
	if(objectid == object)
	{
		SetPVarInt(playerid, "objectid", objectid);

		new Float:oldX, Float:oldY, Float:oldZ,
			Float:oldRotX, Float:oldRotY, Float:oldRotZ;
		GetObjectPos(objectid, oldX, oldY, oldZ);
		GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
		if(!playerobject) // If this is a global object, move it for other players
		{
		    if(!IsValidObject(objectid)) return;
		    MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
		}

		IsEditingObject[playerid] = true;

		if(response == EDIT_RESPONSE_FINAL)
		{
		    IsEditingObject[playerid] = false;
			// The player clicked on the save icon
			// Do anything here to save the updated object position (and rotation)
		}

		if(response == EDIT_RESPONSE_CANCEL)
		{
		    IsEditingObject[playerid] = false;
			//The player cancelled, so put the object back to it's old position
			if(!playerobject) //Object is not a playerobject
			{
				SetObjectPos(objectid, oldX, oldY, oldZ);
				SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
			}
			else
			{
				SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
				SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
			}
		}
	}
	return 1;
}

public OnPlayerSelectDynamicObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
{
	if(objectid == object)
	{
	    if(type == SELECT_OBJECT_GLOBAL_OBJECT)
	    {
			EditDynamicObject(playerid, objectid);
		}
	    else
	    {
	   		EditPlayerObject(playerid, objectid);
	    }
    }
    return 1;
}

CMD:mc(playerid, params[])
{
	new objectid;
	new worldid = GetPlayerVirtualWorld(playerid);
	new Float:x, Float:y, Float:z;
	new Float:x2, Float:y2;
	GetPlayerPos(playerid, x, y, z);
	GetXYInFrontOfPlayer(playerid, x2, y2, 3);
	
    if(sscanf(params, "d", objectid)) return SendClientMessage(playerid, COLOR_GREY, "Użyj: /mc [ID obiektu]");
    if(objectid > 19901 || objectid < 615)
    {
        return SendClientMessage(playerid, COLOR_GREY,"Błąd: Nieprawidłowe ID obiektu");
    }
    else
    {
        object = CreateDynamicObject(objectid, x2, y2, z, 0.0, 0.0, 0.0, worldid, -1, -1, 200.0, 0.0);
        EditDynamicObject(playerid, object);
    }
	return 1;
}

CMD:msel(playerid, params[])
{
    SelectDynamicObject(playerid);
	return 1;
}

CMD:mdel(playerid, params[])
{
	if(IsEditingObject[playerid] == true)
	{
        DestroyObject(GetPVarInt(playerid, "objectid"));
	}
	return 1;
}
Reply
#7

You must follow exact params from streamer.inc natives.
SelectDynamicObject does not exist, please check list of natives before using functions.
Reply
#8

I don't know why people try to use MoveObject() under this callback and expect that to work.
Reply
#9

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I don't know why people try to use MoveObject() under this callback and expect that to work.
Most likely because it's example on Wiki page.
https://sampwiki.blast.hk/wiki/OnPlayerEditObject
Reply
#10

That explains it, I will have to update that today.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)