Random bug? Again?
#1

Hello,

I had this before with Fishing System which is still not fixed (its own script). Now it occures with engine system to.

pawn Код:
new EngineRandom[][] =
{
    {"* Engine started.", 1 },
    {"* Engine start failed.", 0 }
};
. This is the random

pawn Код:
dcmd_engine(playerid,params[])
{
    #pragma unused params
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(PlayerInfo[vehicleid][EngineRunning] == 0)
        {
            new rand = random(sizeof(EngineRandom));
            SendClientMessage(playerid,COLOR_WHITE,EngineRandom[rand][0]);
            PlayerInfo[vehicleid][EngineRunning] = EngineRandom[rand][1];
            TogglePlayerControllable(playerid,0);
        }
        else if(PlayerInfo[vehicleid][EngineRunning] == 1)
        {
            SendClientMessage(playerid,COLOR_WHITE,"* Engine stopped.");
            TogglePlayerControllable(playerid,0);
            PlayerInfo[vehicleid][EngineRunning] = 0;
        }
    }
    else return SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
    return 1;
}
And that is the command.

Now it doesnt start the engine, even when it doesnt fail. What is the problem? :S

Regards, Jochem
Reply
#2

What happens when you use the command do you get one of the messages you scripted or does it just not do anything?
Reply
#3

pawn Код:
PlayerInfo[vehicleid][EngineRunning]
Err, isn't that supposed to be VehicleInfo ^^
Reply
#4

pawn Код:
dcmd_engine(playerid,params[])
{
    #pragma unused params
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(PlayerInfo[vehicleid][EngineRunning] == 0)
        {
            new rand = random(sizeof(EngineRandom));
            SendClientMessage(playerid,COLOR_WHITE,EngineRandom[rand][0]);
            PlayerInfo[vehicleid][EngineRunning] = EngineRandom[rand][1];
            TogglePlayerControllable(playerid,1); // <--- This was 0 (aka, false or frozen)
        }
        else if(PlayerInfo[vehicleid][EngineRunning] == 1)
        {
            SendClientMessage(playerid,COLOR_WHITE,"* Engine stopped.");
            TogglePlayerControllable(playerid,0);
            PlayerInfo[vehicleid][EngineRunning] = 0;
        }
    }
    else return SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
    return 1;
}
Reply
#5

Ok that is fixed.. but now, when the engine is running, and I type /engine again it doesnt turn off. What could that be? It doesnt even give a message. Maybe the variable is set wrong?
Reply
#6

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Ok that is fixed.. but now, when the engine is running, and I type /engine again it doesnt turn off. What could that be? It doesnt even give a message. Maybe the variable is set wrong?
Thats maybe because the "engine" goes on even if the player fails to start the engine

pawn Код:
dcmd_engine(playerid, params[])
{
    #pragma unused params
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(PlayerInfo[vehicleid][EngineRunning] == 0)
        {
            if(random(2) == random(2)) //just out of fun
                return SendClientMessage(playerid, COLOR_WHITE, "* Engine start failed.");
            SendClientMessage(playerid, COLOR_WHITE, "* Engine started.");
            PlayerInfo[vehicleid][EngineRunning] = true;
            TogglePlayerControllable(playerid, true);
        } else {
            SendClientMessage(playerid, COLOR_WHITE, "* Engine stopped.");
            PlayerInfo[vehicleid][EngineRunning] = false;
            TogglePlayerControllable(playerid, false);
        }
        return 1;
    }
    return SendClientMessage(playerid,COLOR_RED,"* You are not in a vehicle.");
}
Reply
#7

How does that work? That wouldn't work?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)