looking for a function -
armyoftwo - 22.08.2010
Hello, i want to make a dynamic gate system what you can create in game.
I'm using AttachObjectToPlayer so the player can put the gate somewhere.
But the problem: "are there any UnAttachPlayerObject " or smth?
Re: looking for a function -
[XST]O_x - 22.08.2010
You can use get the object's positions(GetObjectPos),destroy it,and recreate it using CreateObject in the positions you've stored before.
Re: looking for a function -
armyoftwo - 22.08.2010
the problem is that it always gets rotation "0.0" if i use that
Re: looking for a function -
[XST]O_x - 22.08.2010
So use GetObjectRot?
And of course the float variables has to be global in order for each gate to have it's own variables stored.
Re: looking for a function -
armyoftwo - 22.08.2010
I'm already using that
This is the code i'm using.. maybe the problem is in the code?
Код:
GetObjectPos(Gate[StickedToObject[playerid]], oX, oY, oZ);
GetObjectRot(Gate[StickedToObject[playerid]], xR, yR, zR);
DestroyObject(Gate[StickedToObject[playerid]]);
format(string, sizeof(string), "UPDATE `gates` SET `x` = '%f', `y` = '%f', `z` = '%f', `rot1` = '%f', `rot2` = '%f', `rot3` = '%f' WHERE `SQLID` = '%d'", oX, oY, oZ, xR, yR, zR, StickedToObject[playerid]);
mysql_query(string);
Gate[StickedToObject[playerid]] = CreateObject(newobj, oX, oY, oZ, xR, yR, zR, 100);
StickedToObject[playerid] = 0;
Note the "rot1" , "rot2", "rot3"
Код:
CMySQLHandler::Query(UPDATE `gates` SET `x` = '1487.839965', `y` = '-1736.550048', `z` = '13.392800', `rot1` = '0.000000', `rot2` = '0.000000', `rot3` = '0.000000' WHERE `SQLID` = '3') - Successfully executed.
Re: looking for a function -
[XST]O_x - 22.08.2010
I think there might be a problem since there is one float variable for each gate so they all use the same one.
Try to use something like this:
pawn Код:
forward UnAttachObjectFromPlayer(playerid,objectid,modelid);
public UnAttachObjectFromPlayer(playerid,objectid,modelid)
{
new Float:OPOS[400][6];
GetPlayerObjectPos(playerid,objectid,OPOS[objectid][0],OPOS[objectid][1],OPOS[objectid][2]);
GetPlayerObjectRot(playerid,objectid,OPOS[objectid][3],OPOS[objectid][4],OPOS[objectid][5]);
DestroyPlayerObject(playerid,objectid);
objectid = CreatePlayerObject(playerid,modelid,OPOS[objectid][0],OPOS[objectid][1],OPOS[objectid][2],OPOS[objectid][3],OPOS[objectid][4],OPOS[objectid][5]);
return 1;
}
Unfortunately you're gonna need to place the 'modelid' each time before the recreation.
In your case you can use 'newobj'.
Re: looking for a function -
armyoftwo - 22.08.2010
using your code
Код:
UnAttachObjectFromPlayer(playerid,Gate[StickedToObject[playerid]],GateData[StickedToObject[playerid]][gModel]);
GetObjectPos(Gate[StickedToObject[playerid]], oX, oY, oZ);
GetObjectRot(Gate[StickedToObject[playerid]], xR, yR, zR);
format(string, sizeof(string), "UPDATE `gates` SET `x` = '%f', `y` = '%f', `z` = '%f', `rot1` = '%f', `rot2` = '%f', `rot3` = '%f' WHERE `SQLID` = '%d'", oX, oY, oZ, xR, yR, zR, StickedToObject[playerid]);
mysql_query(string);
//Gate[StickedToObject[playerid]] = CreateObject(GateData[StickedToObject[playerid]][gModel], oX, oY, oZ, xR, yR, zR, 100);
StickedToObject[playerid] = 0;
same
Код:
[22:04:18] CMySQLHandler::Query(UPDATE `gates` SET `x` = '1524.510009', `y` = '-1726.829956', `z` = '15.410599', `rot1` = '0.000000', `rot2` = '0.000000', `rot3` = '0.000000' WHERE `SQLID` = '2') - Successfully executed.
outputs everywhere 0.00000
edit: missed something, testing.
EDIT2: Same