SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 29/01/2007, 01:02 AM   #11
[xA]Ramjet
Big Clucker
 
Join Date: Jan 2007
Posts: 55
Reputation: 0
Default Re: Useful Snippets

Red Alert!
Type: Admin Command.
Description: Kicks all connected players off the server, due to an emergency etc.
_________________________________________________
Global Variable (Top Of Your Script):
Code:
new RedAlertTimer;
_________________________________________________
Function
Code:
public KickAll()
{
	for (new i = 0; i < MAX_PLAYERS; i++)
	{
 		if (IsPlayerConnected(i))
		{
			Kick(i);
		}
	}
}
_________________________________________________
The Command: (Under The OnPlayerCommandText Callback)
Code:
	if (strcmp(cmdtext, "/redalert", true)==0)
	{
	  if(IsPlayerAdmin(playerid))
	  {
	    new string[256];
	    new aname[256];
	    GetPlayerName(playerid,aname,sizeof(aname));
	    GameTextForAll("~r~Red Alert",7000,4);
	    format(string,sizeof(string), "Admin: %s has called Red Alert",aname);
	    SendClientMessageToAll(0xAA3333AA,string);
	    SendClientMessageToAll(0xAA3333AA,"You will all be kicked in ten seconds.");
	    RedAlertTimer = SetTimer("KickAll",10000,0);
	    SendClientMessage(playerid, 0xFFFF00AA, "Red Alert Successful. To Abort Type /abort");
	    printf("%s has initialized the red alert countdown.",aname);
	    return 1;
	  }
	  else
	  {
	    return 0;
	  }
	  return 1;
	}
	if (strcmp(cmdtext, "/abort", true)==0)
	{
	  if(IsPlayerAdmin(playerid))
	  {
	    new string[256];
	    new aname[256];
	    GetPlayerName(playerid,aname,sizeof(aname));
	    GameTextForAll("~y~Red Alert Aborted",7000,4);
	    format(string,sizeof(string), "Admin: %s has canceled the Red Alert",aname);
	    SendClientMessageToAll(0x33AA33AA,string);
	    KillTimer(RedAlertTimer);
	    SendClientMessage(playerid, 0xFFFF00AA, "Red Alert Abort Successful.");
		printf("%s has cancelled the red alert countdown.",aname);
	    return 1;
		}
		else
		{
		  return 0;
		}
        return 1;
	}
_________________________________________________
[xA]Ramjet is offline   Reply With Quote
Old 30/01/2007, 01:20 PM   #12
[QB]Flame^
Little Clucker
 
Join Date: Apr 2006
Posts: 10
Reputation: 0
Default Re: Useful Snippets

Admin Area
Code:
// Set the timer triggering the function which checks if players are in the 'admin' area

SetTimer("AreaCheck", 1000, 1);

// The function

AreaCheck()
{
	for(new i=0; i<MAX_PLAYERS; i++ ) {
		if(IsPlayerConnected(i) && IsPlayerInArea(i, minx, maxx, miny, maxy) && !IsPlayerAdmin(i)) // CHECK: If the player is a admin, if the player is in the area
		{ // He's not.
			SendClientMessage(i, YOURCOLOR, "You are not allowed to enter the ADMIN area.");
			/* Do with him whatever
				you want */
		}
	}
}

// ISPIA Function

IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
return 0;
}

Since it's something most newb scripters want to have, and "cant" find it, i'll post a very basic one. Hopefully this will stop some of the 'I cant find a working code' bs.
[QB]Flame^ is offline   Reply With Quote
Old 30/01/2007, 03:00 PM   #13
boylett
Gangsta
 
Join Date: Jul 2006
Posts: 656
Reputation: 0
Default Re: Useful Snippets

if(IsPlayerConnected(i) && IsPlayerInArea(i, minx, maxx, miny, maxy) && !IsPlayerAdmin(i))
boylett is offline   Reply With Quote
Old 30/01/2007, 05:23 PM   #14
[QB]Flame^
Little Clucker
 
Join Date: Apr 2006
Posts: 10
Reputation: 0
Default Re: Useful Snippets

I really dont see the use of that in this type of function :/ ..
[QB]Flame^ is offline   Reply With Quote
Old 30/01/2007, 06:14 PM   #15
boylett
Gangsta
 
Join Date: Jul 2006
Posts: 656
Reputation: 0
Default Re: Useful Snippets

Code:
SendClientMessage(i, YOURCOLOR, "You are not allowed to enter the ADMIN area.");
What if they leave while in the admin area?
boylett is offline   Reply With Quote
Old 30/01/2007, 06:18 PM   #16
Nitroglycerine
Little Clucker
 
Join Date: Sep 2006
Posts: 40
Reputation: 0
Default Re: Useful Snippets

Quote:
Originally Posted by Flame^
I really dont see the use of that in this type of function :/ ..
Dunno what the function IsPlayerInArea does when you try to check for a playerid that is not connected.... Since that's what's gonna happen sooner or later: you will not always have a full 100 player load on your server.
Nitroglycerine is offline   Reply With Quote
Old 30/01/2007, 11:07 PM   #17
Pixels^
Gangsta
 
Join Date: Dec 2006
Posts: 845
Reputation: 12
Default Re: Useful Snippets

Added OnPlayerConnect for Flame^'s Snippet.

Code:
SetTimer("AreaCheck", 1000, 1);

// The function
Code:
AreaCheck()
{
	for(new i=0; i<MAX_PLAYERS; i++ ) {
        if(IsPlayerConnected(i))
        { 
		   if(IsPlayerInArea(i, minx, maxx, miny, maxy) && !IsPlayerAdmin(i)) // CHECK: If the player is a admin, if the player is in the area
		   { // He's not.
		      SendClientMessage(i, YOURCOLOR, "You are not allowed to enter the ADMIN area.");
			  /* Do with him whatever you want */		
           } 
        }
	}
}
// ISPIA Function
Code:
IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if (x > minx && x < maxx && y > miny && y < maxy) return 1;
return 0;
}
Pixels^ is offline   Reply With Quote
Old 31/01/2007, 11:00 PM   #18
Pixels^
Gangsta
 
Join Date: Dec 2006
Posts: 845
Reputation: 12
Default Re: Useful Snippets

What do i need to edit?
Pixels^ is offline   Reply With Quote
Old 31/01/2007, 11:14 PM   #19
Nitroglycerine
Little Clucker
 
Join Date: Sep 2006
Posts: 40
Reputation: 0
Default Re: Useful Snippets

Quote:
Originally Posted by Pixels^
What do i need to edit?
Perhaps this:
I quote Y_Less:
Moved and pinned, but could I point out that I posted those...
Nitroglycerine is offline   Reply With Quote
Old 02/02/2007, 05:02 AM   #20
Sacky
Big Clucker
 
Join Date: Aug 2006
Posts: 78
Reputation: 0
Default Re: Useful Snippets

Could you give an example of how it could be used? For instance in a str2bin(string[])? I think this could be really useful
Sacky 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 03:55 AM.


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