SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 22/01/2008, 04:57 PM   #121
Rafelder_GRF
Huge Clucker
 
Join Date: Sep 2007
Posts: 220
Reputation: 14
Default Re: Useful Snippets

I hate to use SendRconCommand to set the mapname.
So i scripted this little function.
pawn Code:
stock SetGameMapName(const mapname[])
{
    new string[256];
    format(string, sizeof(string), "mapname %s", mapname);
    SendRconCommand(string);
}
Rafelder_GRF is offline   Reply With Quote
Old 15/02/2008, 10:21 PM   #122
FujiNNN
Huge Clucker
 
FujiNNN's Avatar
 
Join Date: Aug 2006
Location: Russia, Moscow
Posts: 311
Reputation: 0
Default Re: Useful Snippets

Simple Advertiser
by: fujinnn

that script will advertise evry 5 minutes (*you can change) all that you want!

Top of your script:
Code:
forward AutoMsg();
OnGameModeInit()
Code:
SetTimer("AutoMsg",300000,1); // Auto message in evry 5 minutes
Create a new 'public' in the end or middle of your script
Code:
public AutoMsg()
{
	SendClientMessageToAll(0xFF1493AA, "SERVER: *Want to Advertise here? Contact fujinnn");
	return 1;
}
thats it! simple as hell..

[color=red]* that is my first release


enjoy!
FujiNNN is offline   Reply With Quote
Old 01/06/2008, 09:54 PM   #123
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,016
Reputation: 409
Default Re: Useful Snippets

Here is some random useless things for most people!
Prints all the text into 1 file:
Code:
public OnPlayerText(playerid, text[])
{
	new string[256], pname[24], File:ftw = fopen("Text.txt", io_append);
	GetPlayerName(playerid, pname, 24);
	format(string, sizeof (string), "%s:%s \r\n",pname,text);
	fwrite(ftw, string);
	fclose(ftw);
	return 1;
}
Prints all the PM's to a file:
Code:
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	new string[256], pname[24],pname1[24], File:ftw = fopen("PM's.txt", io_append);
	GetPlayerName(playerid, pname, 24);
	GetPlayerName(recieverid, pname, 24);
	format(string, sizeof (string), "From:%s To:%s Message:%s \r\n",pname,pname1,text);
	fwrite(ftw, string);
	fclose(ftw);
	return 1;
}
Prints all the typed commands to a file:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[256], pname[24], File:ftw = fopen("Commands.txt", io_append);
	GetPlayerName(playerid, pname, 24);
	format(string, sizeof (string), "Command:%s Used By:%s \r\n",cmdtext,pname);
	fwrite(ftw, string);
	fclose(ftw);
	return 1;
}
__________________
[HiC]TheKiller is offline   Reply With Quote
Old 11/06/2008, 05:47 PM   #124
boemeles
Gangsta
 
Join Date: Aug 2007
Posts: 814
Reputation: 1
Default Re: Useful Snippets

Count Vehicles In Server

PasteBin link, for ready to use FS

Displays how many vehicles are in your server, only way i could think of, and no fancy shit

news:
pawn Code:
new CounterID, Count, String[32];

command:
pawn Code:
if(!strcmp(cmdtext, "/countcars", true, 10))
    {
      CounterID = playerid;
      for(new i = 0; i < MAX_VEHICLES; i ++)
        SetVehicleToRespawn(i);
      SetTimer("DisplayVehicles", 5000, 0);
      return 1;
    }

Put this in OnVehicleSpawn:
pawn Code:
Count = vehicleid;

And the function to display the amount of cars:
pawn Code:
forward DisplayVehicles();
public DisplayVehicles()
{
    format(String, sizeof(String), "%d Vehicles counted", Count);
    SendClientMessage(CounterID, 0xFFFFFF, String);
}

Im pretty sure someone else's thought of this already, but here is it in the Useful Snippets topic!

EDIT: can this topic be stickied too?
boemeles is offline   Reply With Quote
Old 04/07/2008, 10:28 AM   #125
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,241
Reputation: 3185
Default Re: Useful Snippets

OnServerFrame

This little snippet will cause a callback to be called every server frame. It's operation is fairly obvious as long as you know that sleep(0) does not sleep for exactly 0ms but just >= 0, i.e. it will be called at the next frame greater than 0ms later, not instantly. For this reason the example below may have larger than 0ms gaps (0 is obviously impossible).

This must be put in all your gamemodes if you want it to work consistently, or you can just use th next version of the YSI plugin which will likely include this:

pawn Code:
main()
{
    for ( ; ; )
    {
        sleep (0);
        CallRemoteFunction("OnServerFrame", "");
    }
}

pawn Code:
forward OnServerFrame();

public OnServerFrame()
{
    printf("Elapsed: %d", GetTickCount());
}
Y_Less is online now   Reply With Quote
Old 25/07/2008, 09:30 AM   #126
djnitro
Little Clucker
 
Join Date: Jan 2008
Posts: 28
Reputation: 0
Default Re: Useful Snippets

I made a vehicle-counter Filterscript today . It has some more functions such as model counter and warnings.
And It's written easier without respawning cars or even touching them in any way!! And So u can even use it with all VehicleSlots Used!
DOWNLOAD HERE KLICK

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{

	if (strcmp("/carcheck", cmdtext, true, 10) == 0)
	{
	SendClientMessage(playerid,0xFFFF00AA, "Carcheck introduced!");
	new Models[211]=0;
	new cars=0;
	new mods=0;
	for(new i; i<=MAX_VEHICLES;i++)
		{
			if(400<=GetVehicleModel(i)<=611)
			{
			  cars++;
			  Models[GetVehicleModel(i)-400]=1;
			}
		}
	for(new o;o<=210;o++)
	{
		if(Models[o]==1) mods++;
	}
	new message[256];
	format(message, sizeof(message), "%d cars with %d different models!", cars, mods);
	if(cars>=550)
		{
		  new message2[256];
		  new message21[256];
		  format(message2, sizeof(message2), "Remember you only have %d cars left", 700-cars);
 		  format(message21, sizeof(message21), "And only around %d stable.", 650-mods);
		  SendClientMessage(playerid, 0xFF6347AA, message2);
		  SendClientMessage(playerid, 0xFF6347AA, message21);
 		}
 	if(mods>=50)
		{
		  new message3[256];
		  new message31[256];
		  format(message3, sizeof(message3), "Remember you only have %d models left", 70-mods);
 		  format(message31, sizeof(message31), "And only around %d stable.", 65-mods);
		  SendClientMessage(playerid, 0xFF6347AA, message3);
 		  SendClientMessage(playerid, 0xFF6347AA, message31);
 		}
	SendClientMessage(playerid, 0xFFFF00AA, message);
	return 1;
	}
	return 0;
}
NOTE: this is part of a filterscript. If u wanna use it directly in your gamemode, u have to change the returns at OnPlayerCommandText!
djnitro is offline   Reply With Quote
Old 25/07/2008, 04:21 PM   #127
[D1zZy_vortex]
Big Clucker
 
Join Date: Jul 2008
Posts: 142
Reputation: 0
Default Re: Useful Snippets

To know ur Vehicle id :


Code:

 	if(strcmp(cmdtext, "/vid", true) == 0)
 		{
 		new tmp,str[256];
 		tmp = GetPlayerVehicleID(playerid);
 		format(str,256,"[INFO] Vehicle id: %d",tmp);
 		SendClientMessage(playerid, COLOR_YELLOW, str);
 		return 1;
 		}
[D1zZy_vortex] is offline   Reply With Quote
Old 08/09/2008, 11:31 AM   #128
Serediucr
Huge Clucker
 
Join Date: Jul 2008
Posts: 442
Reputation: 2
Default Re: Useful Snippets

Quote:
Originally Posted by Alejandro
Connect icon in DeathStats from Y_Less
pawn Code:
public OnPlayerConnect(playerid)
{
  SendDeathMessage(playerid, INVALID_PLAYER_ID, 200);
  return 1;
}


Disconnect icon in DeathStats from Y_Less
pawn Code:
public OnPlayerDisconnect(playerid)
{
  SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
}
the disconnect icon shows for me, but the connect icon wont show.
[/quote]
for me is don't showing any icon
Serediucr is offline   Reply With Quote
Old 06/10/2008, 01:57 PM   #129
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 4,213
Reputation: 363
Default Re: Useful Snippets

Anti Labrik Spam
This is defense against the spamming tool which spams your server with "FUCK THIS SERVER" and also spams join/leave. True that it will ban anyone with this name but I don't think someone that uses this name in the first place should join your server. This should be 100% perfect if people do this to your server, as the first join name is Labrik and the first IP is the attackers IP instead of the fake IP's that appear most of the time afterwards.

pawn Code:
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
if(!strcmp("[ViP]Labrik",name,true))
{
Ban(playerid);
}
return 1;
}
__________________
Releases:
[Includes]: [jBan] | [jBanLite]
[Plugins]: [FileManager] | [Execute]
[Applications]: [Remote Administrator *NEW] | [Script King] | [RCON GUI]
JaTochNietDan is offline   Reply With Quote
Old 07/10/2008, 02:33 AM   #130
[ERP]Snow
Big Clucker
 
Join Date: Sep 2008
Posts: 148
Reputation: 0
Default Re: Useful Snippets

Quote:
Originally Posted by JaTochNietDan
Anti Labrik Spam
This is defense against the spamming tool which spams your server with "FUCK THIS SERVER" and also spams join/leave. True that it will ban anyone with this name but I don't think someone that uses this name in the first place should join your server. This should be 100% perfect if people do this to your server, as the first join name is Labrik and the first IP is the attackers IP instead of the fake IP's that appear most of the time afterwards.

pawn Code:
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
if(!strcmp("[ViP]Labrik",name,true))
{
Ban(playerid);
}
return 1;
}
pawn Code:
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
if(!strcmp("[MT]Lavis",name,true))
{
Ban(playerid);
}
return 1;
}
[ERP]Snow 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 12:22 PM


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


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