This is funny,BUT I need help with it!!!
#1

I made this engine system:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
       ToggleEngine(playerid);
       SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
    }
       if((newkeys == KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid)))
       {
          ToggleEngine(playerid);
          SendClientMessage(playerid,BLUE,"The engine is turned on");
       }

    return 1;
}
No compiling errors,and in game it's working,only 1 bug that all the chat is spammed with:"press 2 to turn engine on." How to solve that?
Reply
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   
    if((newkeys == KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid)))
    {
        ToggleEngine(playerid);
        SendClientMessage(playerid,BLUE,"The engine is turned on");
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
       ToggleEngine(playerid);
       SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
    }
}
Reply
#3

Thansk
Reply
#4

Quote:
Originally Posted by xDeadlyBoy
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   
    if((newkeys == KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid)))
    {
        ToggleEngine(playerid);
        SendClientMessage(playerid,BLUE,"The engine is turned on");
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
       ToggleEngine(playerid);
       SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
    }
}
You helping him didn't fix it, it bugged it. The ToggleEngine should only be called once, and thats when the key is pressed not when they enter the vehicle as a driver...think next time.
Reply
#5

oops, you right...
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
       SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)