Onplayerkeystate problem
#1

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  new veh = GetPlayerVehicleID(playerid);
  if(veh == bus3 || veh == bus2 || veh == bus1)
  if (newkeys==KEY_SUBMISSION && IsBusJob[playerid] == 0 && veh == bus1 || veh == bus3 || veh == bus2) // checks if Submission key is pressed + if the player is already working + that the player is in a bus
  {
    SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
    IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
    busdriver[playerid] = 1;
   	SetPlayerCheckpoint(playerid, buspoint1, 3.0);
   	GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
   	new name[MAX_PLAYER_NAME], string[48];
   	GetPlayerName(playerid, name, sizeof(name));
   	format(string, sizeof(string), "%s Is Now A Bus Driver!.", name );
   	SendClientMessageToAll(LIME, string);
  	SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
	}
    return 1;
}
when i enter on bus si i got spam "You Have To Be In A Bus To Start The Mission!|" if a press a up - down -left - right or left or space or whatever so i got spam this msg so can u fix it? and tell me how to add timer when some one enter on bus and leave so again they enter so wait for starting mission.
Reply
#2

Try this:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new veh = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SUBMISSION && IsBusJob[playerid] == 0 && veh == bus1 || veh == bus3 || veh == bus2) // checks if Submission key is pressed + if the player is already working + that the player is in a bus
    {
        SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
        IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
        busdriver[playerid] = 1;
        SetPlayerCheckpoint(playerid, buspoint1, 3.0);
        GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
        new name[MAX_PLAYER_NAME], string[48];
        GetPlayerName(playerid, name, sizeof name);
        format(string, sizeof string, "%s Is Now A Bus Driver!.", name );
        SendClientMessageToAll(LIME, string);
    }
    return 1;
}
Reply
#3

I guess I fixed it.

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  new veh = GetPlayerVehicleID(playerid);
  if(veh == bus3 || veh == bus2 || veh == bus1 && IsBusJob[playerid] == 0) {
  if (newkeys==KEY_SUBMISSION) // checks if Submission key is pressed + if the player is already working + that the player is in a bus
  {
    SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
    IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
    busdriver[playerid] = 1;
   	SetPlayerCheckpoint(playerid, buspoint1, 3.0);
   	GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
   	new name[MAX_PLAYER_NAME], string[48];
   	GetPlayerName(playerid, name, sizeof(name));
   	format(string, sizeof(string), "%s Is Now A Bus Driver!.", name );
   	SendClientMessageToAll(LIME, string); } }
  	else SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
	}
    return 1;
}
Reply
#4

Quote:
Originally Posted by Roach_
Посмотреть сообщение
Try this:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new veh = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SUBMISSION && IsBusJob[playerid] == 0 && veh == bus1 || veh == bus3 || veh == bus2) // checks if Submission key is pressed + if the player is already working + that the player is in a bus
    {
        SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
        IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
        busdriver[playerid] = 1;
        SetPlayerCheckpoint(playerid, buspoint1, 3.0);
        GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
        new name[MAX_PLAYER_NAME], string[48];
        GetPlayerName(playerid, name, sizeof name);
        format(string, sizeof string, "%s Is Now A Bus Driver!.", name );
        SendClientMessageToAll(LIME, string);
    }
    return 1;
}
still spam msg: %s Is Now A Bus Driver! and You started working for the bus compan.
Reply
#5

Quote:
Originally Posted by Rupert
Посмотреть сообщение
I guess I fixed it.

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  new veh = GetPlayerVehicleID(playerid);
  if(veh == bus3 || veh == bus2 || veh == bus1 && IsBusJob[playerid] == 0) {
  if (newkeys==KEY_SUBMISSION) // checks if Submission key is pressed + if the player is already working + that the player is in a bus
  {
    SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
    IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
    busdriver[playerid] = 1;
   	SetPlayerCheckpoint(playerid, buspoint1, 3.0);
   	GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
   	new name[MAX_PLAYER_NAME], string[48];
   	GetPlayerName(playerid, name, sizeof(name));
   	format(string, sizeof(string), "%s Is Now A Bus Driver!.", name );
   	SendClientMessageToAll(LIME, string); } }
  	else SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
	}
    return 1;
}
now bus done but got spam on foot

You Have To Be In A Bus To Start The Mission!
Reply
#6

This should totally work :
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new veh = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SUBMISSION)
    {
        if(veh != bus1 || veh != bus3 || veh != bus2) return SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
        if(IsBusJob[playerid]) return 0;
       
        SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
        IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
        busdriver[playerid] = 1;
        SetPlayerCheckpoint(playerid, buspoint1, 3.0);
        GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
        new name[MAX_PLAYER_NAME], string[48];
        GetPlayerName(playerid, name, sizeof name);
        format(string, sizeof string, "%s Is Now A Bus Driver!.", name );
        SendClientMessageToAll(LIME, string);
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by Roach_
Посмотреть сообщение
This should totally work :
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new veh = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SUBMISSION)
    {
        if(veh != bus1 || veh != bus3 || veh != bus2) return SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
        if(IsBusJob[playerid]) return 0;
       
        SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
        IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
        busdriver[playerid] = 1;
        SetPlayerCheckpoint(playerid, buspoint1, 3.0);
        GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
        new name[MAX_PLAYER_NAME], string[48];
        GetPlayerName(playerid, name, sizeof name);
        format(string, sizeof string, "%s Is Now A Bus Driver!.", name );
        SendClientMessageToAll(LIME, string);
    }
    return 1;
}
when i enter on bus i press to so i get this msg""You Have To Be In A Bus To Start The Mission!"".
Reply
#8

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new veh = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SUBMISSION)
    {
        if(veh != bus1 || veh != bus3 || veh != bus2)
        {
            if(IsBusJob[playerid]) return 0;
       
            SendClientMessage(playerid, LIME, "You started working for the bus company!"); // SCM only one time cause the variable under here.
            IsBusJob[playerid] = 1; // here's the variable set to 1, this will prevent the player from starting working over again.
            busdriver[playerid] = 1;
            SetPlayerCheckpoint(playerid, buspoint1, 3.0);
            GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
            new name[MAX_PLAYER_NAME], string[48];
            GetPlayerName(playerid, name, sizeof name);
            format(string, sizeof string, "%s Is Now A Bus Driver!.", name );
            SendClientMessageToAll(LIME, string);
        } else SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
    }
    return 1;
}
Reply
#9

when i press 2 on foot so they work: You started working for the bus company!"); amd they only worked 1 times the thne if u r on foot or on bus u press 2 not working just work 1 times and then won't. and can i do?

new veh = GetPlayerVehicleID(playerid);
if(newkeys & KEY_SUBMISSION)
{
if(veh != bus1 || veh != bus3 || veh != bus2) return {yourcmdshere] like this work?
Reply
#10

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new veh = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SUBMISSION)
    {
        if(veh == bus1 || veh == bus3 || veh == bus2)
        {
            if(IsBusJob[playerid]) return 0;
       
            SendClientMessage(playerid, LIME, "You started working for the bus company!");
            IsBusJob[playerid] = 1;
            busdriver[playerid] = 1;
            SetPlayerCheckpoint(playerid, buspoint1, 3.0);
            GameTextForPlayer(playerid, "~g~Bus Driver Started!", 3000, 3);
            new name[MAX_PLAYER_NAME], string[48];
            GetPlayerName(playerid, name, sizeof name);
            format(string, sizeof string, "%s Is Now A Bus Driver!.", name );
            SendClientMessageToAll(LIME, string);
        } else SendClientMessage(playerid, COLOR_RED,"You Have To Be In A Bus To Start The Mission!");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)