SA-MP Forums Archive
Slap when car is for another factions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Slap when car is for another factions (/showthread.php?tid=654412)



Slap when car is for another factions - marshmallow - 28.05.2018

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."); }
		}



Re: Slap when car is for another factions - andrejc999 - 28.05.2018

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.


Re: Slap when car is for another factions - marshmallow - 28.05.2018

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


Re: Slap when car is for another factions - andrejc999 - 28.05.2018

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.


Re: Slap when car is for another factions - marshmallow - 28.05.2018

https://*********/9x4YGpcRoH4 like this


Re: Slap when car is for another factions - andrejc999 - 28.05.2018

Код:
//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