12.03.2014, 17:04
pawn Код:
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
{
if(!IsValidObject(objectid)) return 0;
MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
new car = GetPVarInt(playerid, "AttachingTo");
if(car != 0)
{
if(response == EDIT_RESPONSE_FINAL)
{
new carslot = FindFreeObjectSlotInCar(car);
if(carslot == -1)
{
SendClientMessage(playerid, COLOR_RED, "You Cannot Add More Objects On This Vehicle.");
DestroyObject(AttachingObjects[playerid]);
DeletePVar(playerid, "AttachingTo");
return 1;
}
new Float:ofx, Float:ofy, Float:ofz, Float:ofaz;
new Float:finalx, Float:finaly;
new Float:px, Float:py, Float:pz, Float:roz;
new string[128];
GetVehiclePos(car, px, py, pz);
GetVehicleZAngle(car, roz);
ofx = fX-px;
ofy = fY-py;
ofz = fZ-pz;
ofaz = fRotZ-roz;
finalx = ofx*floatcos(roz, degrees)+ofy*floatsin(roz, degrees);
finaly = -ofx*floatsin(roz, degrees)+ofy*floatcos(roz, degrees);
AttachObjectToVehicle(AttachingObjects[playerid], car, finalx, finaly, ofz, fRotX, fRotY, ofaz);
AttachedObjects[car][carslot] = AttachingObjects[playerid];
format(string, sizeof(string), "You Have Attached An Object In Array Slot %d Of Vehicle ID %d.", carslot, car);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
DeletePVar(playerid, "AttachingTo");
return 1;
}
if(response == EDIT_RESPONSE_CANCEL)
{
DestroyObject(AttachingObjects[playerid]);
DeletePVar(playerid, "AttachingTo");
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);
}
}
return 1;
}
}
return 0;
}
pawn Код:
(2876) : warning 209: function "Streamer_OnPlayerEditObject" should return a value
(2900) : error 078: function uses both "return" and "return <value>"
(2903) : error 078: function uses both "return" and "return <value>"
//lines
//2876
if(!IsValidObject(objectid)) return;
//2900
return 1;
//2903
return 0;