Доступ к архиву

Переход в группу "Пользователь"

300.00 ₽
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Приклипление объектов к игроку и создание объектов из игры samp 0.3x

Статус
В этой теме нельзя размещать новые ответы.

Dima972511

Умник
Прикрипление объектов к игроку и создание объектов из игры samp 0.3x

Здравствуйте пользователи p-i вот эта команда позволит вам создавать объекты из игры, и прикреплять их к игроку.
Ко всем командам:
HTML:
CMD:setobject(playerid, params[])
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка  на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Введите: /setobject [id объекта]");
	new Float: x, Float: y, Float: z;
	GetPlayerPos(playerid, x, y, z);
	new objectid = CreateObject(params[0], x, y, z-0.35, 0.0, 0.0, 0.0);
        EditObject(playerid, objectid);
	SetPVarInt(playerid, "ObjectID", objectid);
	SendClientMessage(playerid, COLOR_WHITE, "Объект установлен. Удалить: /removeobject");
	return 1;
}
Куда-нибудь в конец мода:

HTML:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	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);
	}
 
	if(response == EDIT_RESPONSE_FINAL)
	{
		// The player clicked on the save icon
		// Do anything here to save the updated object position (and rotation)
	}
 
	if(response == EDIT_RESPONSE_CANCEL)
	{
		//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);
		}
	}
}
Теперь команда для удаления объекта:

HTML:
CMD:removeobject(playerid, params[])
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
	DestroyObject(GetPVarInt(playerid, "ObjectID"));
    SendClientMessage(playerid, COLOR_WHITE, "Объект удалён");
    return 1;
}
Прикрепление объекта к игроку:

Ко всем командам:
HTML:
CMD:setplayerobject(playerid, params[])
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
	if(sscanf(params, "uddd", params[0], params[1], params[2], params[3])) return SendClientMessage(playerid, COLOR_WHITE, "Введите: /setplayerobject [playerid] [слот] [objectid] [кость]");
	SetPlayerAttachedObject(params[0], params[1], params[2], params[3], 0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
    EditAttachedObject(playerid, params[1]);
    SetPVarInt(playerid, "GetPlayerObject", params[0]);
	SendClientMessage(playerid, COLOR_WHITE, "Вы установили объект игроку");
	return 1;
}
Куда-нибудь в конец мода:

HTML:
public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
                                   Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
                                   Float:fRotX, Float:fRotY, Float:fRotZ,
                                   Float:fScaleX, Float:fScaleY, Float:fScaleZ )
{
    SetPlayerAttachedObject(GetPVarInt(playerid, "GetPlayerObject"),index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
    SendClientMessage(playerid, 0xFFFFFFFF, "Объект установлен");

    return 1;
}
Ну и команда для удаления:
HTML:
CMD:removeplayerobject(playerid, params[])
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
	if(sscanf(params, "ud", params[0], params[1])) return SendClientMessage(playerid, COLOR_WHITE, "Введите: /removeplayerobject [playerid] [слот]");
	RemovePlayerAttachedObject(params[0], params[1]);
	SendClientMessage(playerid, COLOR_WHITE, "Вы удалили объект");
	return 1;
}
Вариант на OnPlayerCommandText:

в OnPlayerCommandText:
HTML:
if(strcmp(cmd, "/setobject", true) == 0)
          {
               if(PlayerLogged[playerid] == false) return 1; // Проверка на авторизацию
               if(PlayerInfo[playerid][pAdmin] < 6) return 1;// Проверка на амдина
               tmp = strtok(cmdtext, idx);
               new object = strval(tmp);
               if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Введите: /setobject [id объекта]");
               new Float: x, Float: y, Float: z;
               GetPlayerPos(playerid, x, y, z);
               new objectid = CreateObject(object, x, y, z-0.35, 0.0, 0.0, 0.0);
               EditObject(playerid, objectid);
	       SetPVarInt(playerid, "ObjectID", objectid);
	       SendClientMessage(playerid, COLOR_WHITE, "Объект установлен. Удалить: /removeobject");
	       return 1;
          }
HTML:
if(strcmp(cmd, "/removeobject", true) == 0)
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
	DestroyObject(GetPVarInt(playerid, "ObjectID"));
        SendClientMessage(playerid, COLOR_WHITE, "Объект удалён");
        return 1;
}
HTML:
if(strcmp(cmd, "/setplayerobject", true) == 0)
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
        tmp = strtok(cmdtext, idx);
        new playa = ReturnUser(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Введите: /setplayerobject [playerid] [слот] [id объекта] [кость]");
        tmp = strtok(cmdtext, idx);
        new slot = strval(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Введите: /setplayerobject [playerid] [слот] [id объекта] [кость]");
        tmp = strtok(cmdtext, idx);
        new object = strval(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Введите: /setplayerobject [playerid] [слот] [id объекта] [кость]");
        tmp = strtok(cmdtext, idx);
        new kost = strval(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Введите: /setplayerobject [playerid] [слот] [id объекта] [кость]");
	SetPlayerAttachedObject(playa, slot, object, kost, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
        EditAttachedObject(playerid, slot);
        SetPVarInt(playerid, "GetPlayerObject", playa);
	SendClientMessage(playerid, COLOR_WHITE, "Вы установили объект игроку");
	return 1;
}
HTML:
if(strcmp(cmd, "/removeplayerobject", true) == 0)
{
	if(PlayerLogged[playerid] == false) return 1; //Проверка на авторизацию
	if(PlayerInfo[playerid][pAdmin] < 6) return 1; //Проверка на админа
	tmp = strtok(cmdtext, idx);
        new playa = ReturnUser(tmp);
        new slot = strval(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0x919191FF, "Введите: /removeplayerobject [playerid] [слот]");
	RemovePlayerAttachedObject(playa, slot);
	SendClientMessage(playerid, COLOR_WHITE, "Вы удалили объект");
	return 1;
}
Куда-нибудь в конец мода:

HTML:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
	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);
	}
 
	if(response == EDIT_RESPONSE_FINAL)
	{
		// The player clicked on the save icon
		// Do anything here to save the updated object position (and rotation)
	}
 
	if(response == EDIT_RESPONSE_CANCEL)
	{
		//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);
		}
	}
}
HTML:
public OnPlayerEditAttachedObject( playerid, response, index, modelid, boneid,
                                   Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
                                   Float:fRotX, Float:fRotY, Float:fRotZ,
                                   Float:fScaleX, Float:fScaleY, Float:fScaleZ )
{
    SetPlayerAttachedObject(GetPVarInt(playerid, "GetPlayerObject"),index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
    SendClientMessage(playerid, 0xFFFFFFFF, "Объект установлен");

    return 1;
}
Все функции тут стандартные с samp 0.3e.

Автор: я.
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу