Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=========================================================================//
- //* SendDialogMessage
- //* Version: 1.1
- //=========================================================================//
- //* Created by:
- //* Biesmen
- //* Reconnect technique thought by JernejL
- //* Making the Kick and BanEx function work without modifying the script by:
- //* KoczkaHUN
- //=========================================================================//
- //* How-To-Use:
- // SendDialogMessage(playerid, message);
- // Kick(playerid, reason);
- // Ban(playerid); - Normal
- // BanEx(playerid); - Normal
- // Reconnect(playerid, reason);
- // ToggleDialogMessage(type, true/false); - Toggle the dialog
- // messages.
- // Types:
- // Kick, Ban, BanEx, Reconnect
- //=========================================================================//
- #include <a_samp>
- new PlayerIP[MAX_PLAYERS][16];
- new pReconnect[MAX_PLAYERS];
- new Activate[4];
- ToggleDialogMessage(type[], bool:tf)
- {
- if(strcmp(type, "Kick", true) == 0)
- {
- if(tf == true)
- {
- Activate[0] = 0;
- }
- else
- if(tf == false)
- {
- Activate[0] = 1;
- }
- }
- else if(strcmp(type, "Ban", true) == 0)
- {
- if(tf == true)
- {
- Activate[1] = 0;
- }
- else
- if(tf == false)
- {
- Activate[1] = 1;
- }
- }
- else if(strcmp(type, "BanEx", true) == 0)
- {
- if(tf == true)
- {
- Activate[2] = 0;
- }
- else
- if(tf == false)
- {
- Activate[2] = 1;
- }
- }
- else if(strcmp(type, "Reconnect", true) == 0)
- {
- if(tf == true)
- {
- Activate[3] = 0;
- }
- else
- if(tf == false)
- {
- Activate[3] = 1;
- }
- }
- else
- {
- printf("ERROR: SendDialogMessage: Type %s is an unkown type.", type);
- }
- return 1;
- }
- stock SendDialogMessage(playerid, message[])
- {
- ShowPlayerDialog(playerid, 8743, DIALOG_STYLE_MSGBOX, "SERVER MESSAGE", message, "Close", "");
- return 1;
- }
- KickEx(playerid, reason[]="")
- {
- new res[128];
- if(Activate[0] == 0)
- {
- if(strlen(reason) == 0)
- {
- SendDialogMessage(playerid, "You got kicked by the server.");
- }
- else
- {
- format(res, sizeof(res), "You got kicked by the server for: %s", reason);
- SendDialogMessage(playerid, res);
- }
- }
- Kick(playerid);
- }
- #if defined _ALS_Kick
- #undef Kick
- #else
- #define _ALS_Kick
- #endif
- #define Kick KickEx
- BanNormal(playerid)
- {
- if(Activate[1] == 1)
- {
- SendDialogMessage(playerid, "You got banned by the server.");
- }
- Ban(playerid);
- }
- #if defined _ALS_Ban
- #undef Ban
- #else
- #define _ALS_Ban
- #endif
- #define Ban BanNormal
- BanEx2(playerid, reason[], name[]="")
- {
- new res[128];
- if(Activate[2] == 0)
- {
- if(strlen(name) == 0)
- {
- format(res, sizeof(res), "You got banned by the server for: %s", reason);
- }
- else
- {
- format(res, sizeof(res), "You got banned by admin: %s for: %s", name, reason);
- }
- SendDialogMessage(playerid, res);
- }
- BanEx(playerid, reason);
- }
- #if defined _ALS_BanEx
- #undef BanEx
- #else
- #define _ALS_BanEx
- #endif
- #define BanEx BanEx2
- Reconnect(playerid, reason[]="")
- {
- new bip[128];
- GetPlayerIp(playerid, PlayerIP[playerid], 16);
- if(Activate[3] == 0)
- {
- if(strlen(reason) == 0)
- {
- format(bip, 44, "You got forced to reconnect by the server.");
- }
- else
- {
- format(bip, 200, "You got forced to reconnect by the server for: %s", reason);
- }
- SendDialogMessage(playerid, bip);
- }
- pReconnect[playerid] = 1;
- TogglePlayerControllable(playerid, false);
- format(bip, sizeof(bip), "banip %s", PlayerIP[playerid]);
- SendRconCommand(bip);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new unban[30];
- if(pReconnect[playerid] == 1)
- {
- format(unban, sizeof(unban), "unbanip %s", PlayerIP[playerid]);
- SendRconCommand(unban);
- pReconnect[playerid] = 0;
- TogglePlayerControllable(playerid, true);
- }
- return (funcidx("ALSOnPlayerDisconnect") != 1)?CallLocalFunction("ALSOnPlayerDisconnect",""):1;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect ALSOnPlayerDisconnect
- forward ALSOnPlayerDisconnect(playerid, reason);
Advertisement
Add Comment
Please, Sign In to add comment