OnPlayerEditObject
#1

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;
Reply
#2

Really need help with this
Reply
#3

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);
            }
    }
}
What now?
Reply
#4

Got alot of more errors now
Reply
#5

then add one more } at the end
Reply
#6

Now you see why indentation is important.
Reply
#7

Quote:
Originally Posted by Matess
Посмотреть сообщение
then add one more } at the end
I have already tried this, it says that i need to return a value.
Reply
#8

and why is there only return?

pawn Код:
if(!IsValidObject(objectid)) return; //change it to return 0; or 1 IDK
Reply
#9

If i compile this as a filterscript, only this with nothing else, it compiles without errors..

So i guess there is nothing wrong with that line
Reply
#10

MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ); That is a silly idea to even try.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)