23.02.2019, 08:40
The problem is when I click the "floppy" icon I got everything back, the checkpoint created but at the same position where I created the ball originally so there is a problem with the GetObjectPos line (I guess). Can someone help me with this?
PHP Code:
new
Float:px,
Float:py,
Float:pz,
cpsize,
policecheckpoint,
ball,
Float:ballx,
Float:bally,
Float:ballz
;
CMD:cptest(playerid, params[])
{
if(sscanf(params, "i", cpsize)) return UsageTag(playerid, "/cptest [SIZE]");
GetPlayerPos(playerid, Float:px, Float:py, Float:pz);
ball = CreateObject(1946, Float:px+1, Float:py+1, Float:pz, -1, -1, -1, 3);
EditObject(playerid, ball);
return 1;
}
hook OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
if(objectid == ball)
{
if(response == EDIT_RESPONSE_FINAL)
{
GetObjectPos(ball, Float:ballx, Float:bally, Float:ballz);
policecheckpoint = CreateDynamicCP(Float:ballx, Float:bally, Float:ballz, cpsize, -1, -1, -1, 100);
ServerTag(playerid, "edit_response_final called");
DestroyObject(ball);
}
}
if(response == EDIT_RESPONSE_CANCEL)
{
DestroyObject(ball);
}
return 1;
}