Is it possible to convert... EditObject and AttachObjectToVehicle -
So that when I use EditObject for an object which is attached to a vehicle, it will de-attach and let me use the editor, when I click save it will then convert the X,Y,Z to the Vehicle Offsets and re-attach?
I need an equasion / algorithm to convert real world GTA X,Y,Z to Vehicle Offsets and vice versa.
Re: Is it possible to convert... EditObject and AttachObjectToVehicle -
Re: Is it possible to convert... EditObject and AttachObjectToVehicle -
so you want to edit Objects with EditObject and after saving the object you want to attach it to a car?
i once worked on a script which should do just that.
but i remember the coordinate conversion worked fine.
I tested it with spoilers as far as i can remember.
PHP код:
/*
================================================================================
__________________________________________________
| ______________________________________________ |
| | ___________ * ______________ | |
| |* | _________| | ____________|* | |
| | | | | | | |
| | | | | | * * | |
| | | | * | | | |
| | | | * | | * | |
| |* | | | | * | |
| | | | * | | * | |
| | | |_________ * | | | |
| | *| _________| | |* * | |
| | | | | |* * | |
| | | | * | | * | |
| | | | * | | | |
| | | | * | | * * | |
| | *| |_________ | |____________* | |
| | |___________| * |______________| | |
| |______________________________________________| |
|__________________________________________________|
================================================================================
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Last line worked on: 187
----------INFO------------
This script's main goal is it to
successfully edit an Object with the EditObject feature
and attach it to a certain vehicle.
Development start: 07.09.2013
Development end: --.--.---
Developer: East_Crips aka Earl_Brown aka TheDarknessBoSS aka CutX
*/
#include <a_samp>
#include <YSI\y_commands>
#include <easydialog>
#define gray 0x8C8C8CFF
#define white 0xFFFFFFFF
#define red 0xFF0000FF
new str8hgn86[90];
#define SFM(%0,%1,%2,%3) format(str8hgn86, sizeof(str8hgn86),%2,%3) && SendClientMessage(%0, %1, str8hgn86)
enum ob_option
{
attached,
ob_name[11],
Float:X,
Float:Y,
Float:Z,
Float:rX,
Float:rY,
Float:rZ,
}
new CO[MAX_PLAYERS][5][ob_option],
MyObjects[MAX_PLAYERS][5],
MyMax[MAX_PLAYERS],
CurrentObject[MAX_PLAYERS][2],
HostCar[MAX_PLAYERS];
main()
{
print("EC-Car Toys has been loaded successfully!");
}
//---------Commands - Main--------
YCMD:cartoys(playerid, params[], help)
{
if(help) return SendClientMessage(playerid,gray,"/cartoys Is used to display the Car-Toys Main Menu.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have to be in your car!");
if(!IsValidVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,red,"This isn't a valid Vehicle!");
ShowDialog(playerid, Show:main, DIALOG_STYLE_LIST, "Menu","Buy new Objects\nEdit an Object\nDelete an Object","Okey","Cancel");
return 1;
}
//--Dialogprocessing - Section----
Dialog:main(playerid, response, listitem, inputtext[])
{
if(!response) return 1;
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have to be in your car!");
switch(listitem)
{
case 0: ShowDialog(playerid, Show:buynew, DIALOG_STYLE_LIST, "Buy new Objects","Spoiler 1\t$5,000\nSpoiler 2\t$5,000\nSpoiler 3\t$5,000\nSpoiler 4\t$5,000\nSpoiler 5\t$5,000\nSpoiler 6\t$5,000\n\
Spoiler 7\t$5,000\nSpoiler 8\t$5,000\nSpoiler 9\t$5,000\nSpoiler 10\t$5,000\nSpoiler 11\t$5,000\nSpoiler 12\t$5,000\nSpoiler 13\t$5,000\nSpoiler 14\t$5,000\nSpoiler 15\t$5,000\nSpoiler 16\t$5,000\n\
Spoiler 17\t$5,000\nSpoiler 18\t$5,000\nSpoiler 19\t$5,000","Buy","Back");
case 1:
{
new tempS[23],s[85];
for(new ob,ov,a=5;ob<a;ob++,ov+=2)
{
format(tempS,sizeof tempS,"%s | Slot %d\n",CO[playerid][ob][ob_name],ov);
strcat(s,tempS);
}
ShowDialog(playerid, Show:edit, DIALOG_STYLE_LIST, "Edit an Object",s,"Edit","Back");
}
case 2: print("2");
}
return 1;
}
Dialog:buynew(playerid, response, listitem, inputtext[])
{
if(!response) return ShowDialog(playerid, Show:main, DIALOG_STYLE_LIST, "Menu","Buy new Objects\nEdit an Object\nDelete an Object","Okey","Cancel");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have to be in your car!");
if(MyMax[playerid] == 5) return SendClientMessage(playerid,red,"You can only have 10 Objects!");
MyMax[playerid]++;
new s[11], n = listitem;
n++;
format(s,sizeof s,"Spoiler %d",n);
CO[playerid][MyMax[playerid]][ob_name] = s;
CO[playerid][MyMax[playerid]][attached] = 0;
switch(listitem)
{
case 0: MyObjects[playerid][MyMax[playerid]] = 1164;
case 1: MyObjects[playerid][MyMax[playerid]] = 1163;
case 2: MyObjects[playerid][MyMax[playerid]] = 1162;
case 3: MyObjects[playerid][MyMax[playerid]] = 1147;
case 4: MyObjects[playerid][MyMax[playerid]] = 1146;
case 5: MyObjects[playerid][MyMax[playerid]] = 1139;
case 6: MyObjects[playerid][MyMax[playerid]] = 1138;
case 7: MyObjects[playerid][MyMax[playerid]] = 1060;
case 8: MyObjects[playerid][MyMax[playerid]] = 1058;
case 9: MyObjects[playerid][MyMax[playerid]] = 1050;
case 10: MyObjects[playerid][MyMax[playerid]] = 1049;
case 11: MyObjects[playerid][MyMax[playerid]] = 1023;
case 12: MyObjects[playerid][MyMax[playerid]] = 1016;
case 13: MyObjects[playerid][MyMax[playerid]] = 1015;
case 14: MyObjects[playerid][MyMax[playerid]] = 1014;
case 15: MyObjects[playerid][MyMax[playerid]] = 1003;
case 16: MyObjects[playerid][MyMax[playerid]] = 1002;
case 17: MyObjects[playerid][MyMax[playerid]] = 1001;
case 18: MyObjects[playerid][MyMax[playerid]] = 1000;
}
SFM(playerid,white,"Object: %s has been added to Slot %d",CO[playerid][MyMax[playerid]][ob_name],MyMax[playerid]);
GivePlayerMoney(playerid,-5000);
return 1;
}
Dialog:edit(playerid, response, listitem, inputtext[])
{
if(!response) return ShowDialog(playerid, Show:main, DIALOG_STYLE_LIST, "Menu","Buy new Objects\nEdit an Object\nDelete an Object","Okey","Cancel");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have to be in your car!");
if(!CO[playerid][listitem][attached])
{
new Float:p[3];
GetVehiclePos(GetPlayerVehicleID(playerid),p[0],p[1],p[2]);
CurrentObject[playerid][0] = CreateObject(MyObjects[playerid][listitem],p[0],p[1],p[2]+1.5,0.0,0.0,0.0);
CO[playerid][listitem][attached] = 1;
}
CurrentObject[playerid][1] = listitem;//Slot
HostCar[playerid] = GetPlayerVehicleID(playerid);
SendClientMessage(playerid,white,"You can now Edit the Object. You can also get out of the car and");
SendClientMessage(playerid,white,"hold the sprint key to get a better view.");
EditObject(playerid,CurrentObject[playerid][0]);
return 1;
}
//--------------------------------
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
new Float:oX, Float:oY, Float:oZ,Float:orX, Float:orY, Float:orZ;
GetObjectPos(objectid, oX, oY, oZ);
GetObjectRot(objectid, orX, orY, orZ);
new Float:vX, Float:vY, Float:vZ;
GetVehiclePos(HostCar[playerid],vX,vY,vZ);
switch(response)
{
case 0:
{
oX = floatsub(oX,vX);
oY = floatsub(oY,vY);
oZ = floatsub(oZ,vZ);
AttachObjectToVehicle(objectid,HostCar[playerid],oX, oY, oZ, orX, orY, orZ);
SendClientMessage(playerid,red,"You canceled the Editing-Mode without saving!");
}
case 1:
{
CO[playerid][CurrentObject[playerid][1]][X] = floatsub(fX,vX);
CO[playerid][CurrentObject[playerid][1]][Y] = floatsub(fY,vY);
CO[playerid][CurrentObject[playerid][1]][Z] = floatsub(fZ,vZ);
CO[playerid][CurrentObject[playerid][1]][rX] = fRotX;
CO[playerid][CurrentObject[playerid][1]][rY] = fRotY;
CO[playerid][CurrentObject[playerid][1]][rZ] = fRotZ;
AttachObjectToVehicle(objectid,HostCar[playerid],CO[playerid][CurrentObject[playerid][1]][X],CO[playerid][CurrentObject[playerid][1]][Y],CO[playerid][CurrentObject[playerid][1]][Z],CO[playerid][CurrentObject[playerid][1]][rX],CO[playerid][CurrentObject[playerid][1]][rY],CO[playerid][CurrentObject[playerid][1]][rZ]);
SendClientMessage(playerid,white,"Successfully edited the Object.");
}
case 2: {}//Editing the object
}
return 1;
}
stock IsValidVehicle(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 417, 425, 447, 460, 469, 476, 487, 488, 497, 511, 512, 513,
519, 520, 548, 553, 563, 577, 592, 593, 509, 481, 510, 462,
448, 581, 522, 461, 521, 523, 463, 586, 468, 471, 472, 473,
493, 595, 484, 430, 453, 452, 446, 454: return 0;
}
return 1;
}
Re: Is it possible to convert... EditObject and AttachObjectToVehicle -
That won't really work very well, besides your better off using commands so you don't lose precision when setting rotations.
Now I think it is possible to do but you would have to have the cars rotation exactly at 0.0 not very practical just use commands.
Re: Is it possible to convert... EditObject and AttachObjectToVehicle -
It can be done, and I can make it for you, but the only problem is that it might take some time to do it.. I'll see what I can come up with in the next few days, and hopefully make an appealing reply to this thread.
Re: Is it possible to convert... EditObject and AttachObjectToVehicle -
Again, it's a bad idea your cars objects will have very poor positioning because editing objects in this way has absolutely no precision so if you have say two of the same objects offset on the x-axis they will never align correctly. I really don't see doing this offering much reward for the effort involved. The fact that no one has really done it yet should be a sign enough given the multiple unsuccessful attempts that it is a bad idea just use commands.