Whats wrong with this? Its annoying!
#1

pawn Код:
CMD:gate(playerid, params[])
{
    static Float:degree, GateOpen;
    degree = 0.5;
    while(degree > 360.0) degree -= 360.0;
    while(degree < 0.0) degree += 360.0;
    if(PlayerInfo[playerid][pTeam] == 6)
    {
        if(GateOpen == 1)
        {
            MoveDynamicObject(ObjClosed, -85.40625000,-1120.18261719, degree, 0.5);
            //SetDynamicObjectRot(ObjClosed, -85.40625000,-1120.18261719, degree);
            GateOpen = 0;
        }
        else if(GateOpen == 0)
        {
            MoveDynamicObject(ObjClosed, -85.40692139,-1120.18322754, degree, 0.5);
            //SetDynamicObjectRot(ObjClosed, 0.0, 0.0, degree);
            GateOpen = 1;
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ORANGE, "INFO: {FFFFFF}You are not an Courier.");
    }
    return 1;
}
Yes, I know it will be wrong, I just can't figure it out.
Reply
#2

Why are you declaring static variables? And why are you using a while statement instead of an if statement? Your code isn't logical.
Reply
#3

Okay, i've updated it a little,
pawn Код:
CMD:ogate(playerid, params[])
{
    new Float:degree;
    degree = 0.3;
    if(PlayerInfo[playerid][pTeam] == 6)
    {
        //MoveDynamicObject(ObjClosed, -85.40625000,-1120.18261719, -0.0001, 0.5);
        SetDynamicObjectRot(ObjClosed, -85.40625000,-1120.18261719, -0.0001);
    }
    else
    {
        SendClientMessage(playerid, COLOR_ORANGE, "INFO: {FFFFFF}You are not an Courier.");
    }
    return 1;
}

CMD:cgate(playerid, params[])
{
    new Float:degree;
    degree = 0.0001;
    if(PlayerInfo[playerid][pTeam] == 6)
    {
        //MoveDynamicObject(ObjClosed, -85.40692139,-1120.18322754, 0.0001, 0.5);
        SetDynamicObjectRot(ObjClosed, -85.40692139,-1120.18322754, 0.0001);
    }
    else
    {
        SendClientMessage(playerid, COLOR_ORANGE, "INFO: {FFFFFF}You are not a Courier.");
    }
    return 1;
}
Reply
#4

I could do with this being fixed so I can move on.
Reply
#5

Try 180.0 for ogate and 0.0 for cgate (in SetDynamicObjectRot).
Reply
#6

It now works but not the way I want it to, the coords are messed up, I know they're the correct ones though.
Reply
#7

Quote:
Originally Posted by -Luis
Посмотреть сообщение
I could do with this being fixed so I can move on.
Well then fix it yourself you've already been told your code isn't even logical and now you speak like you have the right to make other people code for you?

pawn Код:
new bool:GATE_STATUS;
COMMAND:gate(playerid,params[])
{
    if(PlayerInfo[playerid][pTeam] == 6) {
        switch(GATE_STATUS) {
            case false:
            {
                MoveDynamicObject(ObjClosed, -85.40625000,-1120.18261719, 4321, 0.5);
            }
            case true:
            {
                MoveDynamicObject(ObjClosed, -85.40692139,-1120.18322754, 1234, 0.5);
            }
        }
    }
    else {
        return SendClientMessage(playerid, COLOR_ORANGE, "INFO: {FFFFFF}You are not an Courier.");
    }
    return true;
}


public OnDynamicObjectMoved(objectid)
{
    switch(objectid) {
        case ObjClosed:
        {
            new Float:x, Float:y, Float:z;
            GetDynamicObjectPos(ObjClosed, x, y, z);
            if(x == -85.40625000 && y == -1120.18261719 && z == 4321) {
                GATE_STATUS = true;
            }
            else if(x == -85.40625000 && y == -1120.18261719 && z == 1234) {
                GATE_STATUS = false;
            }
        }
    }
    return true;
}
Here's an example, use it wisely and maybe try it yourself next time.
Reply
#8

Quote:
Originally Posted by -Luis
Посмотреть сообщение
...the coords are messed up, I know they're the correct ones though.
The coords are correct but they are not correct
Reply
#9

I'm having trouble with this;
pawn Код:
public OnDynamicObjectMoved(objectid)
{
    switch(objectid) {
        case ObjClosed: // This line.
        {
            SendClientMessageToAll(COLOR_YELLOW, "ObjClosed object found.");
            new Float:x, Float:y, Float:z, string[128];
            SendClientMessageToAll(COLOR_YELLOW, "Getting Coords.");
            GetDynamicObjectPos(ObjClosed, x, y, z);
            SendClientMessageToAll(COLOR_YELLOW, "Matching coords.");
            if(GATE_STATUS == 0) {
                GATE_STATUS = 1;
                format(string, sizeof(string), "GATE: X = %f, Y = %f, Z = %f. Gate Status = %d", x, y, z, GATE_STATUS);
                SendClientMessageToAll(COLOR_YELLOW, string);
            }
            else if(GATE_STATUS == 1) {
                SendClientMessageToAll(COLOR_YELLOW, "Matching Coords #2");
                GATE_STATUS = 0;
                format(string, sizeof(string), "GATE: X = %f, Y = %f, Z = %f. Gate Status = %d", x, y, z, GATE_STATUS);
                SendClientMessageToAll(COLOR_YELLOW, string);
            }
        }
    }
    return 1;
}
The error
Код:
error 008: must be a constant expression; assumed zero
Reply
#10

Switch case can only be followed by number.
You can do string switch case tho' with YSI (forgot the include name).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)