Shift Key start engine problem
#1

Hey All

I have this Engine system, I want to make it with the cmd /engine And with the key of shift, When i push shift its starts the engine..


This is the lines:
pawn Код:
if(strcmp(cmd, "/start", true) == 0)//start
    {
      if(IsPlayerConnected(playerid))
        {
          if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0))
  if(newkeys == KEY_JUMP)
            {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "  %s has attempted to Start the vehicle", sendername);
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                printf("%s", string);
              EnterCarTime[playerid] += 1;
            return 1;
            }
            else
            {
              SendClientMessage(playerid, COLOR_GREY, "  You are not in a Vehicle!");
            return 1;
            }
        }
    }
    if(strcmp(cmd,"/stop", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            if(IsPlayerInAnyVehicle(playerid))
            {
              new VID;
              VID = GetPlayerVehicleID(playerid);
              if(CarRunning[VID] == 1)
              {
                GetPlayerName(playerid,sendername,sizeof(sendername));
                format(string, sizeof(string), "** %s Turns Their Car off.",sendername);
          ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                TogglePlayerControllable(playerid, 0);
                CarRunning[VID] = 0;
                }
                else
                {
                  SendClientMessage(playerid, COLOR_GREY, " Your car is already off.");
                  return 1;
                }
            }
            else
            {
              SendClientMessage(playerid, COLOR_GREY, " You are not in a car !");
              return 1;
            }
        }
    }
And this too:
pawn Код:
if(EnterCarTime[i] >= 1)//start
            {
              EnterCarTime[i] += 1;
              VID = GetPlayerVehicleID(i);
              GetVehicleHealth(VID, Vehhp);
              if(EnterCarTime[i] == 3)
              {
                if(CarWires[VID] == 0 && Vehhp > 400 && Gas[VID] > 3)
                {
                        SendClientMessage(i, TEAM_GROVE_COLOR, "  The engine is now running, Drive Safely");
                    TogglePlayerControllable(i, 1);
                    CarRunning[VID] = 1;
                    EnterCarTime[i] = 0;
                    }
                    else
                    {
                      SendClientMessage(i, COLOR_RED,"  You failed to start your car ");
                      SendClientMessage(i, COLOR_RED, "  Check your engine!");
                      EnterCarTime[i] = 0;
                    }
              }
            }
Last one:
pawn Код:
if(CarRunning[newcar] == 0)
        {
      new vehicleid;
            vehicleid = GetPlayerVehicleID(playerid);
            if(IsABicyle(newcar))
            {
            SendClientMessage(playerid, COLOR_PURPLE, "Status: Ready to ride.");
                return 1;
        }
            if(IsARC(vehicleid))
            {
            SendClientMessage(playerid, COLOR_PURPLE, "Status: Ready to drive.");
                return 1;
        }
            TogglePlayerControllable(playerid, 0);
            SendClientMessage(playerid, COLOR_PURPLE, "Status: To start the engine, Switch the car keys by(Shift Key)OR(/engine)");
        }
        if(CarRunning[newcar] == 1)
        {
            SendClientMessage(playerid, COLOR_LIGHTGREEN, "Status: The engine is Running ");
        }
        if(CarWires[newcar] != 0)
        {
          SendClientMessage(playerid, COLOR_RED, "Status: Ignition wires are damaged ");
        }
        if(Vehhp <= 400)
        {
          SendClientMessage(playerid, COLOR_RED, "Status: **Engine light indicates** Engine Repairs needed.");
      ShowPlayerDialog(playerid, MECHANICMENU, DIALOG_STYLE_LIST, "What would you like to do?","Call Mechanic\nExit Vehicle ", "Select", "Cancel");
        }
        if(Gas[newcar] < 4)
        {
          SendClientMessage(playerid, COLOR_RED, "  Status: **Fuel Light Indicates** Re-Fill needed. ");
          ShowPlayerDialog(playerid, MECHANICMENU, DIALOG_STYLE_LIST, "What would you like to do?","Call Mechanic\nExit Vehicle ", "Select", "Cancel");
        }
        if(IsABoat(newcar))
        {
          if(PlayerInfo[playerid][pBoatLic] < 1)
            {
              SendClientMessage(playerid, COLOR_GREY, "  You don't know how to Sail yet, so you left the Boat !");
              RemovePlayerFromVehicle(playerid);
              TogglePlayerControllable(playerid, 1);
            }
        }
Well, Ive putted all of these 3 codes, If you need them, I dont know How to add it on my gm..

What I want is, That the /start will be same, PLUS the Key Shift

Thanks All!!
I'll Be very thankful The oen who can help me!
Reply
#2

Anyone ?
Reply
#3

the keys should be added under : OnPlayerKeyStateChange
not under : OnPlayerCommandText
Reply
#4

This is my Public of the key:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if (IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
  {
      if(IsPlayerConnected(playerid))
        {
      if (PlayerInfo[playerid][pMember] == 8 && PlayerInfo[playerid][pLeader] == 8)
      {
        if(PlayerInfo[playerid][pC4Used] == 0)
        {
                CreateExplosion(bx, by, bz, 7, 4);
                PickUpC4(playerid);
                PlayerInfo[playerid][pC4Used] = 1;
                }
            }
            new string[128];
            if(editingcdvehpos[playerid])
            {
                TogglePlayerControllable(playerid, false);
                format(string,256,"Is this the new position you want?.");
            ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
            }
            if(editingcdvehnew[playerid])
            {
        TogglePlayerControllable(playerid, false);
        format(string,256,"Is this the new position you want?.");
            ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
            }
        }
  }
    return 1;
}
How to add it?
Reply
#5

try this :
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0)) {
  if(newkeys == KEY_JUMP)
			{
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(string, sizeof(string), "  %s has attempted to Start the vehicle", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				printf("%s", string);
			  EnterCarTime[playerid] += 1;
		  	return 1;
			}
			else
			{
			  SendClientMessage(playerid, COLOR_GREY, "  You are not in a Vehicle!");
		  	return 1;
			}
		}
  if (IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
  {
	  if(IsPlayerConnected(playerid))
		{
      if (PlayerInfo[playerid][pMember] == 8 && PlayerInfo[playerid][pLeader] == 8)
      {
        if(PlayerInfo[playerid][pC4Used] == 0)
        {
	     		CreateExplosion(bx, by, bz, 7, 4);
	    		PickUpC4(playerid);
	    		PlayerInfo[playerid][pC4Used] = 1;
				}
			}
			new string[128];
			if(editingcdvehpos[playerid])
			{
				TogglePlayerControllable(playerid, false);
				format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
			if(editingcdvehnew[playerid])
			{
        TogglePlayerControllable(playerid, false);
        format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
		}
  }
	return 1;
}
Reply
#6

Quote:
Originally Posted by Etch ❽ H
try this :
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0)) {
 if(newkeys == KEY_JUMP)
			{
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(string, sizeof(string), " %s has attempted to Start the vehicle", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				printf("%s", string);
			  EnterCarTime[playerid] += 1;
		  	return 1;
			}
			else
			{
			  SendClientMessage(playerid, COLOR_GREY, " You are not in a Vehicle!");
		  	return 1;
			}
		}
  if (IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
  {
	  if(IsPlayerConnected(playerid))
		{
      if (PlayerInfo[playerid][pMember] == 8 && PlayerInfo[playerid][pLeader] == 8)
      {
        if(PlayerInfo[playerid][pC4Used] == 0)
        {
	     		CreateExplosion(bx, by, bz, 7, 4);
	    		PickUpC4(playerid);
	    		PlayerInfo[playerid][pC4Used] = 1;
				}
			}
			new string[128];
			if(editingcdvehpos[playerid])
			{
				TogglePlayerControllable(playerid, false);
				format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
			if(editingcdvehnew[playerid])
			{
        TogglePlayerControllable(playerid, false);
        format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
		}
  }
	return 1;
}
I get these:
Код:
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4247) : error 017: undefined symbol "sendername"
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4247) : error 017: undefined symbol "sendername"
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4247) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4247) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#7

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0)) {
  if(newkeys == KEY_JUMP)
			{
                new sendername[MAX_PLAYER_NAME];
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(string, sizeof(string), "  %s has attempted to Start the vehicle", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				printf("%s", string);
			  EnterCarTime[playerid] += 1;
		  	return 1;
			}
			else
			{
			  SendClientMessage(playerid, COLOR_GREY, "  You are not in a Vehicle!");
		  	return 1;
			}
		}
  if (IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
  {
	  if(IsPlayerConnected(playerid))
		{
      if (PlayerInfo[playerid][pMember] == 8 && PlayerInfo[playerid][pLeader] == 8)
      {
        if(PlayerInfo[playerid][pC4Used] == 0)
        {
	     		CreateExplosion(bx, by, bz, 7, 4);
	    		PickUpC4(playerid);
	    		PlayerInfo[playerid][pC4Used] = 1;
				}
			}
			new string[128];
			if(editingcdvehpos[playerid])
			{
				TogglePlayerControllable(playerid, false);
				format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
			if(editingcdvehnew[playerid])
			{
        TogglePlayerControllable(playerid, false);
        format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
		}
  }
	return 1;
}
Reply
#8

add this under OnPlayerKeyStateChange
Код:
new sendername[MAX_PLAYER_NAME];
Edit : Picharlo sendername is not a variable its a name
Reply
#9

Quote:
Originally Posted by Etch ❽ H
add this under OnPlayerKeyStateChange
Код:
new sendername[MAX_PLAYER_NAME];
Edit : Picharlo sendername is not a variable its a name
Thanks for information, edited post.
Reply
#10

Well, This is my public now And I gety these:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new sendername[MAX_PLAYER_NAME];
  if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0)) {
  if(newkeys == KEY_JUMP)
			{
				new sendername[MAX_PLAYER_NAME];
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(string, sizeof(string), "  %s has attempted to Start the vehicle", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				printf("%s", string);
			  EnterCarTime[playerid] += 1;
		  	return 1;
			}
			else
			{
			  SendClientMessage(playerid, COLOR_GREY, "  You are not in a Vehicle!");
		  	return 1;
			}
		}
  if (IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
  {
	  if(IsPlayerConnected(playerid))
		{
      if (PlayerInfo[playerid][pMember] == 8 && PlayerInfo[playerid][pLeader] == 8)
      {
        if(PlayerInfo[playerid][pC4Used] == 0)
        {
	     		CreateExplosion(bx, by, bz, 7, 4);
	    		PickUpC4(playerid);
	    		PlayerInfo[playerid][pC4Used] = 1;
				}
			}
			new string[128];
			if(editingcdvehpos[playerid])
			{
				TogglePlayerControllable(playerid, false);
				format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
			if(editingcdvehnew[playerid])
			{
        TogglePlayerControllable(playerid, false);
        format(string,256,"Is this the new position you want?.");
		    ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
			}
		}
  }
	return 1;
}
Код:
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4248) : warning 219: local variable "sendername" shadows a variable at a preceding level
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4250) : error 017: undefined symbol "string"
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4250) : error 017: undefined symbol "string"
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4250) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\щемзп дтбегд\SunRise Roleplay\gamemodes\srrp.pwn(4250) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)