SA-MP Forums Archive
Random bug? Again? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random bug? Again? (/showthread.php?tid=174324)



Random bug? Again? - Jochemd - 05.09.2010

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


Re: Random bug? Again? - iggy1 - 05.09.2010

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


Re: Random bug? Again? - Hiddos - 05.09.2010

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


Re: Random bug? Again? - LarzI - 05.09.2010

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;
}



Re: Random bug? Again? - Jochemd - 05.09.2010

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?


Re: Random bug? Again? - Nero_3D - 05.09.2010

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.");
}



Re: Random bug? Again? - Jochemd - 10.09.2010

How does that work? That wouldn't work?