All pastes #983638 Raw Edit

Something

public text v1 · immutable
·published 2008-04-13 15:15 UTC
rendered paste body
// ***************************************************
//        IRC Plugin 1.1 ECHO FILTERSCRIPT          //
//   coded by Jacob. (irc.gtanet.com:6667 #jacob) 	//
// ***************************************************


// INCLUDES
// ----------------------------------------------
#include <a_samp>
#include <dutils>
#pragma unused ret_memcpy
#if defined _irc_included
	#endinput
#endif
#define _irc_included

native ircConnect(server[], port, user[]);
native ircDisconnect(conn);
native ircSay(conn, channel[], message[]);
native ircJoinChan(conn, channel[]);
native ircPartChan(conn, channel[]);
native ircSetMode(conn, channel[], modes[], nicks[]);
native ircGetUserLevel(conn, channel[], user[], dest[]);
native ircGetUserList(conn, channel[], dest[], size);
native ircSendRawData(conn, rawdata[]);
native ircPollEvents();
forward ircOnConnect(conn);
forward ircOnUserSay(conn, channel[], user[], message[]);
forward ircOnUserPart(conn, channel[], user[]);
forward ircOnUserJoin(conn, channel[], user[]);

// DECLARATIONS
// ----------------------------------------------
new EchoConnection; 			// This will hold the connection ID for messages.
new EchoChan[20] = "#partyrmx-server";	// This is the channel you want your echo to be in, as well as the !say command.
new bool:TimerSet = false;  	// Prevents the timer from being set multiple times.
forward EventTimer();       	// Forward declaration for Event Timer (explained later)
new Connections = 0;

// Weapon name credits to Simon's Debug FS
new aWeaponNames[][32] = {
	{"Unarmed (Fist)"}, // 0
	{"Brass Knuckles"}, // 1
	{"Golf Club"}, // 2
	{"Night Stick"}, // 3
	{"Knife"}, // 4
	{"Baseball Bat"}, // 5
	{"Shovel"}, // 6
	{"Pool Cue"}, // 7
	{"Katana"}, // 8
	{"Chainsaw"}, // 9
	{"Purple Dildo"}, // 10
	{"Big White Vibrator"}, // 11
	{"Medium White Vibrator"}, // 12
	{"Small White Vibrator"}, // 13
	{"Flowers"}, // 14
	{"Cane"}, // 15
	{"Grenade"}, // 16
	{"Teargas"}, // 17
	{"Molotov"}, // 18
	{" "}, // 19
	{" "}, // 20
	{" "}, // 21
	{"Colt 45"}, // 22
	{"Colt 45 (Silenced)"}, // 23
	{"Desert Eagle"}, // 24
	{"Normal Shotgun"}, // 25
	{"Sawnoff Shotgun"}, // 26
	{"Combat Shotgun"}, // 27
	{"Micro Uzi (Mac 10)"}, // 28
	{"MP5"}, // 29
	{"AK47"}, // 30
	{"M4"}, // 31
	{"Tec9"}, // 32
	{"Country Rifle"}, // 33
	{"Sniper Rifle"}, // 34
	{"Rocket Launcher"}, // 35
	{"Heat-Seeking Rocket Launcher"}, // 36
	{"Flamethrower"}, // 37
	{"Minigun"}, // 38
	{"Satchel Charge"}, // 39
	{"Detonator"}, // 40
	{"Spray Can"}, // 41
	{"Fire Extinguisher"}, // 42
	{"Camera"}, // 43
	{"Night Vision Goggles"}, // 44
	{"Infrared Vision Goggles"}, // 45
	{"Parachute"}, // 46
	{"Fake Pistol"} // 47
};

new aDisconnectNames[][16] = {
	{"Timeout"}, // 0
	{"Left"}, // 1
	{"Kicked"} // 2
};

// onFilterScriptInit function
// ----------------------------------------------
// This is where you will typically call all of the required ircConnects.
// ircConnect will return the connection ID.  You will use this ID with all of your natives and callbacks.
public OnFilterScriptInit()
{
    EchoConnection = ircConnect("irc.gtanet.com", 6667, "RMX_Server");
	return 1;
}

public OnFilterScriptExit()
{
	ircDisconnect(EchoConnection);
	return 1;
}

// Event timer
// ----------------------------------------------
// The event timer is something new in 1.1. It tells the plugin to cycle through the event que and call each callback.
// It is REQUIRED if you want these functions to be called:
// ircOnUserSay, ircOnUserPart, and ircOnUserJoin.
public EventTimer()
{
	TimerSet = true;
	ircPollEvents();
}

public ircOnConnect(conn)
{
	ircJoinChan(conn, EchoChan);                    // join the echo channel
	if (!TimerSet) SetTimer("EventTimer", 500, 1);  // listen for callbacks from this channel
	Connections++;                                  // save number of connections
	ircSendRawData(conn, "PRIVMSG NickServ :IDENTIFY asd");
}

// ircIsOp stock
// This stock gets the user level in the requested channel, and compares with: ~, &, or @.
// If any of the levels match, stock returns true.  (else, stock return false)
// ----------------------------------------------
stock ircIsOp(conn,channel[],user[])
{
	new ircLevel[4];
	ircGetUserLevel(conn, channel, user, ircLevel);
	if(!strcmp(ircLevel, "~", true,1) || !strcmp(ircLevel, "&", true,1) || !strcmp(ircLevel, "@", true,1)) return 1;
	return 0;
}

// ircOnUserSay callback
// This is called when the plugin receives PRIVMSG: either you received a PM or a message in a joined channel.
// Commands are parsed using a modified DCMD (DracoBlue's Fast Command Processor)
// ----------------------------------------------
public ircOnUserSay(conn, channel[], user[], message[])
{
	if(!ircIsOp(conn,channel,user))return 1;
	new cmd[256];
	
	if(!strcmp(message, "!players", true)){
		for(new g=0;g<200;g++)if(IsPlayerConnected(g)){
			new name[32], msg[256];
			GetPlayerName(g, name, sizeof(name));
			new ip[20];
			GetPlayerIp(g, ip, 20);
			format(msg, sizeof(msg), "<\2;%s\2;>2[%i : %s] ", name, g, ip);
			ircSay(conn, channel, msg);
		}
		return 1;
	}
	
	if(message[0]=='!'){
	
		for(new i=0;i<strlen(message)+1;i++)cmd[i]=message[i];
		cmd[0]='/';
		CallRemoteFunction("IRCCommands", "ds", 234, cmd);
		return 1;
	}
	
	format(cmd, 256, "IRC * Admin %s mówi: %s", user, message);
	SendClientMessageToAll(0xFFFFFFFF, cmd);
	return 1;
}

// User join/part callbacks, called when a user joins the CHANNEL.  Not the game.
// I didn't do anything when this happened in the filterscript, but you can easily with the callbacks below.
// ----------------------------------------------
public ircOnUserPart(conn, channel[], user[])
{
	return 1;
}

public ircOnUserJoin(conn, channel[], user[])
{
	return 1;
}

// Some default SA:MP callbacks, we're just going to echo a few of them.
// ----------------------------------------------
public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	new msg[128];
	new name[32];
	GetPlayerName(playerid, name, sizeof(name));
	format(msg, sizeof(msg), "2*** \2;%s\2; wszedl na server.", name);
	ircSay(EchoConnection, EchoChan, msg);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new msg[128];
	new name[32];
	GetPlayerName(playerid, name, sizeof(name));
	format(msg, sizeof(msg), "2*** \2;%s\2; wyszedl z servera. (2%s)", name, aDisconnectNames[reason]);
	ircSay(EchoConnection, EchoChan, msg);
	return 1;
}

public OnPlayerText(playerid, text[])
{
	new msg[128];
	new name[32];
	GetPlayerName(playerid, name, sizeof(name));
	format(msg, sizeof(msg), "2[%i] <\2;%s\2;> %s", playerid, name, text); // [0] <jacob> hi
	ircSay(EchoConnection, EchoChan, msg);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new msg[128];
	new name[32];
	GetPlayerName(playerid, name, sizeof(name));
	format(msg, sizeof(msg), "2[%i] <\2;%s\2;> %s", playerid, name, cmdtext); // [0] <jacob> hi
	ircSay(EchoConnection, EchoChan, msg);
	return 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	new msg[128];
	new playername[32];
	new killername[32];
	GetPlayerName(playerid,playername,32);
	if ((reason == 255) || (killerid == 255))
	{
	    format(msg, sizeof(msg), "*** \2;%s\2; zabil sie.", playername);
	    goto snd;
	}
	else
	{
	    GetPlayerName(killerid,killername,32);
	    format(msg, sizeof(msg), "*** \2;%s\2; zostal zabity przez \2;%s\2;. (2%s)", playername, killername, aWeaponNames[reason]);
    }
snd:
	printf("msg: %s\n", msg);
	ircSay(EchoConnection, EchoChan, msg);
	return 1;
}