Public feed
#600929
#include <a_samp>#include <a_irc>#include <global>#define ECHO_CHANNEL "#jacob"#define ECHO_SERVER "irc.gtanet.com"#define ECHO_NICK "Simon|Echo"#define ECHO_PASSWORD ""#define ECHO_PORT 6667#define ADMIN_CHANNEL "#jacob"// IRC Example script// by Jacobmain(){}public OnFilterScriptInit( ){ ircConnect( ECHO_SERVER, ECHO_PORT, ECHO_NICK, ECHO_PASSWORD ); return 0;}public OnFilterScriptExit( ){ ircDisconnect( ); return 0;}// This gets executed once you have connected to a channelpublic ircOnConnect(){ ircJoinChan( ECHO_CHANNEL );}// This gets executed when someone says something in a channel you are in.public ircOnUserSay(channel[], user[], message[]){ new msg[512]; format(msg,sizeof(msg), "[%s] <%s> %s", channel, user, message); SendClientMessageToAll(0xFFFFFFFF, msg); if ( !strcmp( channel, ADMIN_CHANNEL, true ) ) { if ( !strcmp( message, "!say", true, 4 ) ) { new len = strlen( message[ 4 ] ); if ( len > 40 ) { return ircSay( channel, "04ERROR: Message too large." ); } else if ( !len ) { return ircSay( channel, "05USAGE: !say [msg]" ); } else { new str[ 128 ]; format( str, 127, "(IRC) %s: %s", user, message[ 5 ] ); SendClientMessageToAll( 0x2587CEFF, str ); format( str, 127, "10%s", str ); ircSay( channel, str ); return 1; } } else if ( !strcmp( message, "!asay", true, 5 ) ) { new len = strlen( message[ 5 ] ); if ( len > 40 ) { return ircSay( channel, "04ERROR: Message too large." ); } if ( !len ) { return ircSay( channel, "05USAGE: !asay [msg]" ); } else { new str[ 128 ]; format( str, 127, "(A-IRC) %s: %s", user, message[ 6 ] ); SendClientMessageToAdmins( 0xFF0000FF, str ); format( str, 127, "04%s", str ); ircSay( channel, str ); return 1; } } else if ( !strcmp( message, "!kill", true, 5 ) ) { if ( !strlen( message[ 6 ] ) || !IsNumeric( message[ 6 ] ) ) { return ircSay( channel, "05USAGE: !kill [id]" ); } new killID = strval( message[ 6 ] ); if ( !IsPlayerConnected( killID ) ) { return ircSay( channel, "04ERROR: That playerid is not connected!" ); } SetPlayerHealth( killID, 0.0 ); } else if ( !strcmp( message, "!msg", true, 4 ) || !strcmp( message, "!pm", true, 3 ) ) { new str[ 128 ], idx, msgID, msgLen; strtok( message, idx ); str = strtok( message, idx ); msgLen = strlen( message[ idx + 1 ] ); if ( !strlen( str ) || !msgLen || !IsPlayerConnected( msgID ) || !IsNumeric( str ) ) { return ircSay( channel, "05USAGE: !msg [id] [msg]" ); } msgID = strval( str ); if ( !IsPlayerConnected( msgID ) ) { return ircSay( channel, "04ERROR: That playerid is not connected!" ); } if ( msgLen > 40 ) { return ircSay( channel, "04ERROR: Message too large." ); } new Float:pX, Float:pY, Float:pZ; GetPlayerPos( msgID, pX, pY, pZ ); PlayerPlaySound( msgID, 1139, pX, pY, pZ ); GameTextForPlayer( msgID, "~n~~n~~n~~n~~n~~n~~n~~n~~n~ ~y~New Personal Message ...", 5000, 3 ); format( str, 127, "PM from %s (IRC): %s", user, message[ idx + 1 ] ); SendClientMessage( msgID, 0xFFFF00FF, str ); GetPlayerName( msgID, str, MAX_PLAYER_NAME ); format( str, 127, "10PM to %s (ID:%d): %s", str, msgID, message[ idx + 1 ] ); ircSay( channel, str ); return 1; } else if ( !strcmp( message, "!getip", true, 6 ) ) { if ( !strlen( message[ 7 ] ) || !IsNumeric( message[ 7 ] ) ) { return ircSay( channel, "05USAGE: !getip [id]" ); } new ipID = strval( message[ 6 ] ); if ( !IsPlayerConnected( ipID ) ) { return ircSay( channel, "04ERROR: That playerid is not connected!" ); } new IP[ 16 ], str[ 65 ]; GetPlayerName( ipID, str, MAX_PLAYER_NAME ); GetPlayerIp( ipID, IP, 16 ); format( str, 64, "07%s's IP: %s", str, IP ); ircSay( channel, str ); return 1; } } return 1;}// This gets executed when someone parts a channel you are in.public ircOnUserPart(channel[], user[]){ new msg[112]; format(msg,sizeof(msg), "[%s] %s left the channel.", channel, user); SendClientMessageToAll(0xFFFFFFFF, msg); return 1;}// This gets executed when someone joins a channel you are in.public ircOnUserJoin(channel[], user[]){ new msg[112]; format(msg,sizeof(msg), "[%s] %s joined the channel.", channel, user); SendClientMessageToAll(0xFFFFFFFF, msg); return 1;}public OnGameModeInit(){ ircSay( ECHO_CHANNEL, "Gamemode loaded." ); return 0;}public OnGameModeExit(){ ircSay( ECHO_CHANNEL, "Gamemode exited." ); return 0;}public OnPlayerConnect( playerid ){ new str[ 65 ]; GetPlayerName( playerid, str, MAX_PLAYER_NAME ); format( str, 64, "02[%d] 03*** %s joined the game. ", playerid, str ); ircSay( ECHO_CHANNEL, str ); return 0;}public OnPlayerDisconnect( playerid, reason ){ new str[ 65 ], sReason[ 32 ]; switch( reason ) { case 0: sReason = "Timeout"; case 1: sReason = "Quit"; case 2: sReason = "Kicked"; } GetPlayerName( playerid, str, MAX_PLAYER_NAME ); format( str, 64, "02[%d] 03*** %s left the game (%s). ", playerid, str, sReason ); ircSay( ECHO_CHANNEL, str ); return 0;}public OnPlayerPrivmsg( playerid, recieverid, text[] ){}public OnPlayerDeath( playerid, killerid, reason ){ new str[ 65 ], kName[ MAX_PLAYER_NAME ], wName[ 24 ]; GetPlayerName( playerid, str, MAX_PLAYER_NAME ); if ( reason == 18 ) wName = "Molotov"; else if ( reason == 255 ) wName = "Unknown"; else GetWeaponName( reason, wName, 24 ); if ( killerid != INVALID_PLAYER_ID ) { GetPlayerName( killerid, kName, MAX_PLAYER_NAME ); format( str, 64, "04*** %s killed %s. (%s) ", kName, str, wName ); } else { format( str, 64, "04*** %s died (%s). ", str, wName ); } ircSay( ECHO_CHANNEL, str ); return 0;}public OnPlayerText( playerid, text[ ] ){ new str[ 128 ]; GetPlayerName( playerid, str, MAX_PLAYER_NAME ); format( str, 127, "02[%d] 07%s: %s", playerid, str, text ); ircSay( ECHO_CHANNEL, str ); return 1;}stock IsNumeric(const string[]) { new length=strlen(string); if (length==0) return false; for (new i = 0; i < length; i++) { if ( (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-' || (string[i]=='-' && i!=0) // A '-' but not at first. || (string[i]=='+' && i!=0) // A '+' but not at first. ) return false; } if (length==1 && (string[0]=='-' || string[0]=='+')) return false; return true;}