SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 14/05/2014, 03:01 AM   #1
MasonSFW
Huge Clucker
 
MasonSFW's Avatar
 
Join Date: Feb 2014
Location: Thailand
Posts: 302
Reputation: 14
Default Stop player shooting on vehicles [First tutorial]

Hello this first tutorial

What is can do?:

This can stop player shooting on vehicles.

Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
   	if(GetPlayerWeapon(playerid) != 29) // MP5
           {
      		SetPlayerArmedWeapon(playerid, 0);
           }
     }
     return 1;
}
or

Code:
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!
__________________
5.175.181.128:7777 - Updated 2015

Join us, Great community .

_________________________________________________
My work:
MasonSFW is offline   Reply With Quote
Old 14/05/2014, 04:51 AM   #2
Lordzy
High-roller
 
Lordzy's Avatar
 
Join Date: Mar 2012
Location: NetherRealm
Posts: 2,698
Reputation: 1177
Default Re: Stop player shooting on vehicles [First tutorial]

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.
Lordzy is offline   Reply With Quote
Old 14/05/2014, 05:09 AM   #3
nilanjay
Huge Clucker
 
Join Date: May 2011
Location: India
Posts: 365
Reputation: 13
Default Re: Stop player shooting on vehicles [First tutorial]

I will suggest read this document: http://forum.sa-mp.com/showthread.php?t=65567 on "How to Write a Tutorial" by ******.
__________________

Releases

nilanjay is offline   Reply With Quote
Old 19/05/2014, 08:05 AM   #4
ExtendedCarbon
Big Clucker
 
Join Date: Jun 2013
Posts: 64
Reputation: 1
Default Re: Stop player shooting on vehicles [First tutorial]

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
Code:
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.
ExtendedCarbon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] How to map + Adding maps / vehicles ( All in one ) ( Tutorial ) Lapon Tutorials 2 22/12/2012 08:12 AM
|[>|<]| RC Vehicles & Tram Einsteig Function || RC Tank Shooting |[>|<]| asdfgh98 Filterscripts 5 20/12/2012 02:14 PM
convertFFS Vehicles! [Awesome tools to speed up working with vehicles] kc Filterscripts 34 18/06/2009 11:34 PM


All times are GMT. The time now is 10:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.