Slap when car is for another factions
#1

Hi i want when a playerwants to enter factions cars If not for her faction (automatic slapped for 4sec)
Код:
if(IsACopCar(newcar))
		{
		    if(IsACop(playerid))
			{
				if(OnDuty[playerid] != 1) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "You are not on duty."); }
			}
		    else { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "This vehicle is locked to group Los Santos Police Department."); }
		}
		if(IsAFbiCar(newcar))
		{
		    if(IsACop(playerid))
			{
				if(OnDuty[playerid] != 1) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "You are not on duty."); }
			}
		    else { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "This vehicle is locked to group Federal Bureau of Investigations."); }
		}
		if(IsALVPDCar(newcar))
		{
		    if(IsACop(playerid))
			{
				if(OnDuty[playerid] != 1) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "You are not on duty."); }
			}
		    else { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "This vehicle is locked to group Las Venturas Police Department."); }
		}
		if(IsANgCar(newcar))
		{
		    if(IsACop(playerid))
			{
				if(OnDuty[playerid] != 1) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "You are not on duty."); }
			}
		    else { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid,COLOR_WHITE, "This vehicle is locked to group National Guard."); }
		}
Reply
#2

So you want a player to get slapped if he/she tries to enter a car from another faction?

Just check for the vehicle in OnPlayerEnterVehicle https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle and add this:

Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);//Gets players position
SetPlayerPos(playerid, X, Y, Z+5);//Adds 5 to players Z coord, also slaps the player. Change 5 to what you think is good.
EDIT: I don't know what you mean by 'slapped for 4 seconds', you can freeze the player for 4 seconds if you want to but I don't think it's necessary.
Reply
#3

Quote:
Originally Posted by andrejc999
Посмотреть сообщение
So you want a player to get slapped if he/she tries to enter a car from another faction?

Just check for the vehicle in OnPlayerEnterVehicle https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle and add this:

Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);//Gets players position
SetPlayerPos(playerid, X, Y, Z+5);//Adds 5 to players Z coord, also slaps the player. Change 5 to what you think is good.
EDIT: I don't know what you mean by 'slapped for 4 seconds', you can freeze the player for 4 seconds if you want to but I don't think it's necessary.
https://*********/9x4YGpcRoH4 see this video like tiss
Reply
#4

What's the point in slapping a player for 4 seconds? I mean if he gets slapped he already gets warned for entering the vehicle + the animation gets stopped so he can't enter the car. So if you really want to do this you could set players pos higher up and check in-game for how long he stays in the air.
Reply
#5

https://*********/9x4YGpcRoH4 like this
Reply
#6

Код:
//add this on top of the script under other new/static statements
new SlapCD[MAX_PLAYERS];
new slapped[MAX_PLAYERS];
//after setting players position add this
TogglePlayerControllable(playerid, false);
SlapCD[playerid] = gettime() + 4;
slapped[playerid] = 1;
//under OnPlayerUpdate:
if(SlapCD[playerid] <= gettime() && slapped[playerid] == 1)
{
    TogglePlayerControllable(playerid, true);
    slapped[playerid] = 0;
}
//Add this under OnPlayerConnect:
slapped[playerid] = 0;
SlapCD[playerid] = 0;
That SlapCD thing works like a timer without using a timer so it doesn't use many resources like the timer does.

Rep if I helped
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)