SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 21/10/2009, 09:22 PM   #251
FreshKilla
Big Clucker
 
FreshKilla's Avatar
 
Join Date: Feb 2008
Location: Canada
Posts: 149
Reputation: 7
Default Re: Useful Snippets

Anti Drive By + Blocks weapons if there synced from the SA-MP bug.

pawn Code:
public OnPlayerUpdate(playerid)
{
  if(!IsPlayerConnected(playerid)) return 0;

  new gun = GetPlayerWeapon(playerid);

  if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  {
    if(gun == 28 || gun == 29 || gun == 32)
    {
      SetPlayerArmedWeapon(playerid,0);
      return 0;
    }
  }

  return 1;
}
FreshKilla is offline   Reply With Quote
Old 23/10/2009, 03:34 PM   #252
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 3,352
Reputation: 354
Default Re: Useful Snippets

Quote:
Originally Posted by FreshKilla [PR-RP
]
Anti Drive By + Blocks weapons if there synced from the SA-MP bug.
There have been better versions of anti drive by in 0.2 (it just needed some storage)
the only improvement is the new function SetPlayerArmedWeapon
__________________


Nero_3D is offline   Reply With Quote
Old 25/10/2009, 05:18 PM   #253
Google63
Banned
 
Join Date: Jun 2008
Posts: 166
Reputation: 0
Default Re: Useful Snippets

Useful macros:

Code:
#define isEven(%1) \
        (!((%1)&(01)))
Code:
 
#define isPowerOfTwo(%1) \
        (!(%1)&(%1-1))
Google63 is offline   Reply With Quote
Old 12/11/2009, 10:20 PM   #254
smeti
Huge Clucker
 
smeti's Avatar
 
Join Date: Sep 2008
Posts: 326
Reputation: 32
Default Re: Useful Snippets

Updated RcVehicles system 0.3 samp version.

Code:
IsVehicleRc(vehicleid)
{
  	switch(GetVehicleModel(vehicleid)){
		case 441, 464, 465, 501, 564, 594: return true;
	}
	return false;
}

Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new
		Float:x,
		Float:y,
		Float:z;
	if(newkeys == KEY_SECONDARY_ATTACK )
	{
		new VehicleSeat = GetPlayerVehicleSeat(playerid);
		if(VehicleSeat == -1)
		{
			for(new forvehicleid; forvehicleid < MAX_VEHICLES; forvehicleid++)
			{
				if(!IsVehicleRc(forvehicleid)) continue;
				GetVehiclePos(forvehicleid, x, y, z);
				if(IsPlayerInRangeOfPoint(playerid, 6, x, y, z))
				{
					PutPlayerInVehicle(playerid, forvehicleid, 0);
					break;
				}
			}
		}
		else if(VehicleSeat == 0)
		{
			if(IsVehicleRc(GetPlayerVehicleID(playerid)))
			{
				GetPlayerPos(playerid, x, y, z);
				SetPlayerPos(playerid, x+1, y, z+1.0);
			}
		}
	}
	if(newkeys == KEY_FIRE || newkeys == 12 || newkeys == 36)
	{
		if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 564)
		{
			new Float:angle;
			GetPlayerPos(playerid,x,y,z);
			GetVehicleZAngle(GetPlayerVehicleID(playerid), angle);
			x += (30 * floatsin(-angle + 5, degrees));
			y += (30 * floatcos(-angle + 5, degrees));
			CreateExplosion(x,y,z,3,4.0);
		}
	}
	return 1;
}
smeti is offline   Reply With Quote
Old 21/11/2009, 11:33 PM   #255
FreshKilla
Big Clucker
 
FreshKilla's Avatar
 
Join Date: Feb 2008
Location: Canada
Posts: 149
Reputation: 7
Default Re: Useful Snippets

Anti Non-RP Car jack, Ideal for RP servers.

pawn Code:
if(!ispassenger)
  {
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER)
      {
        new Float:cx, Float:cy, Float:cz;
        GetPlayerPos(playerid, cx, cy, cz);
        SetPlayerPos(playerid, cx, cy, cz);
        SendClientMessage(playerid,COLOR_GREY," Someone is driving this vehicle, You must take it Properly !");
      }
    }
  }
FreshKilla is offline   Reply With Quote
Old 23/11/2009, 07:15 PM   #256
radi
Big Clucker
 
Join Date: Aug 2008
Posts: 186
Reputation: 0
Default Re: Useful Snippets

where do i have tho place that code freshkilla ?
radi is offline   Reply With Quote
Old 23/11/2009, 07:29 PM   #257
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Re: Useful Snippets

Quote:
Originally Posted by radi
where do i have tho place that code freshkilla ?
OnPlayerEnterVehicle-callback.
Correlli is offline   Reply With Quote
Old 26/11/2009, 12:47 PM   #258
gtaturke54
Little Clucker
 
Join Date: Mar 2009
Posts: 16
Reputation: 0
Default Re: Useful Snippets

itīs not from me, but this is cool:

Code:
if(strcmp(cmd, "/haha", true) == 0)
 {
 new player;
 tmp = strtok(cmdtext, idx);
 if(!strlen(tmp))
 {
  SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /haha [playerid]");
 }
 
 player = ReturnUser(tmp);
 if (player == playerid)
 {
  SendClientMessage(player, COLOR_RED, "You canīt laugh at yourself!");
  return 1;
 }
 if(IsPlayerConnected(player))
 {
   if(player != INVALID_PLAYER_ID)
   {
   new string[128];
  GetPlayerName(playerid, sendername, sizeof(sendername));
  format(string, sizeof(string), "* %s laughs at you!", sendername);
  SendClientMessage(playerid,COLOR_RED,string);
  }
  }
		return 1;
		}
gtaturke54 is offline   Reply With Quote
Old 26/11/2009, 09:08 PM   #259
heufix
Big Clucker
 
Join Date: May 2009
Posts: 70
Reputation: 7
Default Re: Useful Snippets

Code:
if(strcmp(cmd, "/haha", true) == 0)
 {
 new player = ReturnUser(tmp);
 tmp = strtok(cmdtext, idx);
 if(!strlen(tmp)) SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /haha [playerid]");
 if (player == playerid) return SendClientMessage(player, COLOR_RED, "You canīt laugh at yourself!");
 if(!IsPlayerConnected(player)) return SendClientMessage(playerid,COLOR_RED,"Invalid Playerid");
  new string[128];
  GetPlayerName(playerid, sendername, sizeof(sendername));
  format(string, sizeof(string), "* %s laughs at you!", sendername);
  SendClientMessage(playerid,COLOR_RED,string);
    return 1;
    }
heufix is offline   Reply With Quote
Old 26/11/2009, 09:09 PM   #260
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Posts: 7,035
Reputation: 103
Default Re: Useful Snippets

This is wrong, this will get the name of the player who used the command and it will send the message to him.
Correlli 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
READ Usefull Links to snippets and other -Sneaky- Help Archive 5 02/05/2009 11:22 AM


All times are GMT. The time now is 11:57 PM.


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