25.07.2017, 13:43
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.
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.
|
#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); }
new inCar = 0; new playingMiniGame= 0;
playingMiniGame = 1;
inCar = 1;
if(playingMiniGame == 1 && inCar == 1){ SendClientMessage(playerid, 0x00FF00FF, "You can't exit vehicle while on event."); return 1; }
I think the only way to do this is using the function PutPlayerInVehicle under OnPlayerExitVehicle. Using TogglePlayerControllable freezes the player entirely
|
Clearplayeranimation(playerid)