[Tutorial] Stop player shooting on vehicles [First tutorial] - 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)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Stop player shooting on vehicles [First tutorial] (
/showthread.php?tid=513029)
Stop player shooting on vehicles [First tutorial] -
MasonSFW - 14.05.2014
Hello this first tutorial
What is can do?:
This can stop player shooting on vehicles.
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(GetPlayerWeapon(playerid) != 29) // MP5
{
SetPlayerArmedWeapon(playerid, 0);
}
}
return 1;
}
or
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(GetPlayerWeapon(playerid) == 29 )
{
SetPlayerArmedWeapon(playerid, 0);
}
}
}
return 1;
}
You can use this to stop player shooting on vehicle in your gamemode!
Re: Stop player shooting on vehicles [First tutorial] -
Lordzy - 14.05.2014
It's a tutorial board and you've to EXPLAIN the snippet you posted! And your first code won't avoid driveby as you're checking if it's not MP5. Also, MP5 isn't the only weapon which allows driveby.
Re: Stop player shooting on vehicles [First tutorial] -
nilanjay - 14.05.2014
I will suggest read this document:
https://sampforum.blast.hk/showthread.php?tid=65567 on "How to Write a Tutorial" by ******.
Re: Stop player shooting on vehicles [First tutorial] -
ExtendedCarbon - 19.05.2014
I would suggest removing the weapon check if(GetPlayerWeapon(playerid) != 29) and just set the players armed weapon to 0 when they enter a car at all.
Like this
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SetPlayerArmedWeapon(playerid, 0);
}
return 1;
}
This code works, so whenever someone gets inside any seat of a car their weapons are set to fists.