Making it so players can't exit vehicles?
#3

Quote:
Originally Posted by TheLeech
Посмотреть сообщение
How to make it so players can't leave a car, I'm making a minigame / event system for my server and don't want players to be able to exit the cars when playing, Can't figure it out.
I used this in my server, just figure it out. ( I dont know if it will work to you)

Код:
#define REMOVETYPE_EXIT_VEHICLE 	1

stock RemoveFromDerby(playerid, removetype = REMOVETYPE_QUIT_SERVER)
{
	new
	    string[ 96 ],
	    timeplayed
	;
	SetVehicleVirtualWorld(pInfo[ playerid ][ VehicleID ], 1);

	dInfo[ VehicleOccupied ][ pInfo[ playerid ][ VehicleID ] ] = false;
	dInfo[ ActivePlayers ]--;
	pInfo[ playerid ][ InDerby ] = false;

	SetPlayerPos(playerid, 0, 0, 0);

	switch(removetype)
	{
	    case REMOVETYPE_QUIT_SERVER:
	    {
	        format(string, sizeof(string), ">> %s(ID: %d) left (%d/%d players)", pInfo[ playerid ][ Name ], playerid, dInfo[ ActivePlayers ]+1, dInfo[ TotalPlayers ]);
			SendClientMessageToAll(0xf3ec13AA, string);

			if(dInfo[ ActivePlayers ] == 1)
			{
			    foreach(Player, i)
			    {
			        if(pInfo[ i ][ InDerby ] == false) continue;
			        GameTextForPlayer(i, "~g~WINNER", 2500, 3);
			        format(string, sizeof(string), ">> %s(ID: %d) wins (position: %d/%d)", pInfo[ i ][ Name ], i, dInfo[ ActivePlayers ], dInfo[ TotalPlayers ]);
					GivePlayerScore(i, 5);
			        break;
				}
				dInfo[ DerbyEnded ] = true;
				SendClientMessageToAll(0xf3ec13AA, string);
				//SetTimer("ResetDerby", 3000, false);
			}
		}
		case REMOVETYPE_EXIT_VEHICLE:
		{
		    timeplayed = gettime() - pInfo[ playerid ][ StartTime ];

			GameTextForPlayer(playerid, "~r~LOST", 2500, 3);
		    format(string, sizeof(string), ">> %s(ID: %d) lost (exit vehicle, position: %d/%d, time: %d seconds)", pInfo[ playerid ][ Name ], playerid, dInfo[ ActivePlayers ]+1, dInfo[ TotalPlayers ], timeplayed);
			SendClientMessageToAll(0xf3ec13AA, string);

			if(dInfo[ ActivePlayers ] == 1)
			{
			    foreach(Player, i)
			    {
			        if(pInfo[ i ][ InDerby ] == false) continue;
			        GameTextForPlayer(i, "~g~WINNER", 2500, 3);
			        format(string, sizeof(string), ">> %s(ID: %d) wins (position: %d/%d)", pInfo[ i ][ Name ], i, dInfo[ ActivePlayers ], dInfo[ TotalPlayers ]);
			        GivePlayerScore(i, 5);
			        break;
				}
				dInfo[ DerbyEnded ] = true;
				SendClientMessageToAll(0xf3ec13AA, string);
				//SetTimer("ResetDerby", 3000, false);
			}
		}
		case REMOVETYPE_IDLE:
		{
      		timeplayed = gettime() - pInfo[ playerid ][ StartTime ];

		    GameTextForPlayer(playerid, "~r~LOST", 2500, 3);
		    format(string, sizeof(string), ">> %s(ID: %d) lost (idle, position: %d/%d, time: %d seconds)", pInfo[ playerid ][ Name ], playerid, dInfo[ ActivePlayers ]+1, dInfo[ TotalPlayers ], timeplayed);
			SendClientMessageToAll(0xf3ec13AA, string);

			if(dInfo[ ActivePlayers ] == 1)
			{
			    foreach(Player, i)
			    {
			        if(pInfo[ i ][ InDerby ] == false) continue;
			        GameTextForPlayer(i, "~g~WINNER", 2500, 3);
			        format(string, sizeof(string), ">> %s(ID: %d) wins (position: %d/%d)", pInfo[ i ][ Name ], i, dInfo[ ActivePlayers ], dInfo[ TotalPlayers ]);
			        GivePlayerScore(i, 5);
			        break;
				}
				dInfo[ DerbyEnded ] = true;
				SendClientMessageToAll(0xf3ec13AA, string);
				//SetTimer("ResetDerby", 3000, false);
			}
		}
		case REMOVETYPE_FELL:
		{
      		timeplayed = gettime() - pInfo[ playerid ][ StartTime ];

		    GameTextForPlayer(playerid, "~r~LOST", 2500, 3);
		    format(string, sizeof(string), ">> %s(ID: %d) lost (fell, position: %d/%d, time: %d seconds)", pInfo[ playerid ][ Name ], playerid, dInfo[ ActivePlayers ]+1, dInfo[ TotalPlayers ], timeplayed);
			SendClientMessageToAll(0xf3ec13AA, string);

			if(dInfo[ ActivePlayers ] == 1)
			{
			    foreach(Player, i)
			    {
			        if(pInfo[ i ][ InDerby ] == false) continue;
			        GameTextForPlayer(i, "~g~WINNER", 2500, 3);
			        format(string, sizeof(string), ">> %s(ID: %d) wins (position: %d/%d)", pInfo[ i ][ Name ], i, dInfo[ ActivePlayers ], dInfo[ TotalPlayers ]);
			        GivePlayerScore(i, 5);
			        break;
				}
				dInfo[ DerbyEnded ] = true;
				SendClientMessageToAll(0xf3ec13AA, string);
				//SetTimer("ResetDerby", 3000, false);
			}
		}
	}
	if(dInfo[ ActivePlayers ] <= 1 || dInfo[ TotalPlayers ] <= 1)
	{
	    dInfo[ DerbyEnded ] = true;
	    foreach(Player, i)
	    {
			if(GetPlayerState( i ) == PLAYER_STATE_SPECTATING) TogglePlayerSpectating(i, false);
			else SetPlayerPos(i, 0, 0, 0);
		}
		SetTimer("ResetDerby", 5000, false);
	}
	else if(dInfo[ ActivePlayers ] > 1)
	{
	    pInfo[ playerid ][ SpectateID ] = INVALID_PLAYER_ID;
		foreach(Player, i)
	 	{
			if(pInfo[ i ][ InDerby ] == false) continue;
	  		else pInfo[ playerid ][ SpectateID ] = i;
		}
		if(pInfo[ playerid ][ SpectateID ] != INVALID_PLAYER_ID)
		{
            TogglePlayerSpectating(playerid, true), PlayerSpectateVehicle(playerid, GetPlayerVehicleID( pInfo[ playerid ][ SpectateID ] ));
			TextDrawShowForPlayer(playerid, gSpecInfo[0]), TextDrawShowForPlayer(playerid, gSpecInfo[1]), TextDrawShowForPlayer(playerid, gSpecInfo[2]);
			UpdateSpecInfo(playerid);
		}
	}
	format(string, sizeof( string ), "Players in derby: ~y~%d/%d", dInfo[ ActivePlayers ], dInfo[ TotalPlayers ]);
	TextDrawSetString(gCounterInfo, string);
	TextDrawShowForAll(gCounterInfo);
}
Reply


Messages In This Thread
Making it so players can't exit vehicles? - by TheLeech - 25.07.2017, 13:43
Re: Making it so players can't exit vehicles? - by TonyII - 25.07.2017, 13:53
Re: Making it so players can't exit vehicles? - by DonaldDuck - 25.07.2017, 13:54
Re: Making it so players can't exit vehicles? - by Kenny164 - 26.07.2017, 07:09
Re: Making it so players can't exit vehicles? - by Xtra - 26.07.2017, 07:30
Re: Making it so players can't exit vehicles? - by Sew_Sumi - 26.07.2017, 08:40
Re: Making it so players can't exit vehicles? - by Xtra - 26.07.2017, 08:43
Re: Making it so players can't exit vehicles? - by R4nd4ll - 26.07.2017, 11:27

Forum Jump:


Users browsing this thread: 6 Guest(s)