Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ============================|Walkie Talkie System|============================
- |==============================================================================|
- |______________________________________________________________________________|
- | Version: v1.0 |
- | Author: Captive |
- | Credits: Captive |
- |______________________________________________________________________________|
- Vietata la rimozione dei crediti
- Use:
- - / Wtmenu to access the menu of the Walkie Talkie to turn it on, turn it off or
- select the frequency, send a sound to the channel
- - /wt [text] to talk through Walkie Talkie
- */
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #define COLOR_INFO 0xFFFFFFFF //White
- #define COLOR_ERROR 0xFF0000FF //Red
- #define COLOR_ME 0x9ACD32AA //Light Green
- #define COLOR_WT 0xFF9900AA //Orange
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xFF0000FF
- #define DIALOG_WTMENU 0
- #define DIALOG_WTCH 3
- enum wtsystem
- {
- bool:wtOn,
- wtChannel
- };
- new Wt_Info[MAX_PLAYERS][wtsystem];
- new stringa[256], pName[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("*==========================================*");
- print("| Walkie Talkie System . by Captive |");
- print("| ... ... ... Loaded! |");
- print("*==========================================*");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, COLOR_WT, "[Use]: /wtmenu to access the menu Walkie Talkie and / wt to talk");
- Wt_Info[playerid][wtOn] = false;
- Wt_Info[playerid][wtChannel] = -1;
- return 1;
- }
- forward StopUseWalkieTalkie(playerid);
- forward PlayerPlaySoundToChannel(channel);
- //------------------------------------------------------------------------------
- CMD:wtmenu(playerid, params[])
- {
- if(Wt_Info[playerid][wtOn] == false)ShowPlayerDialog(playerid, DIALOG_WTMENU, DIALOG_STYLE_LIST, "Walkie Talkie Menu", "On", "Confirm", "Cancel");
- else ShowPlayerDialog(playerid, DIALOG_WTMENU, DIALOG_STYLE_LIST, "Walkie Talkie Menu", "Off\nFrequency\nAlert Channel", "Confirm", "Cance");
- return 1;
- }
- CMD:wt(playerid, params[])
- {
- new wtMessage[256];
- if(sscanf(params, "s", wtMessage))return SendClientMessage(playerid, COLOR_INFO, "[Use]: /wt [testo]");
- if(Wt_Info[playerid][wtOn] != true)return SendClientMessage(playerid, COLOR_ERROR, "[Error]: {FFFFFF}Your Walkie Talkie is powered off. Use /wtmenu to turn it on");
- if(Wt_Info[playerid][wtChannel] == -1)return SendClientMessage(playerid, COLOR_ERROR, "[Error]: {FFFFFF}Your Walkie Talkie is not set to any frequency. Use /wtmenu to set");
- GetPlayerName(playerid, pName, 24);
- format(stringa, sizeof(stringa), "[WT] %s say: {FFFFFF}%s",pName, wtMessage);
- SendClientMessageToChannel(Wt_Info[playerid][wtChannel], COLOR_WT, stringa);
- SendRangedMessage(playerid, COLOR_INFO, stringa, 15.0);
- if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_USECELLPHONE && GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_STOPUSECELLPHONE)
- {
- SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
- SetTimerEx("StopUseWalkieTalkie", 3100, false, "i", playerid);
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- GetPlayerName(playerid, pName, 24);
- if(dialogid == DIALOG_WTMENU)
- {
- if(response)
- {
- format(stringa, sizeof(stringa), "*%s extracts a Walkie talkie and press the keys*", pName);
- switch(listitem)
- {
- case 0:
- {
- if(Wt_Info[playerid][wtOn] == false)
- {
- SendClientMessage(playerid, COLOR_INFO, "[Info]: Did you turn on the Walkie Talkie");
- Wt_Info[playerid][wtOn] = true;
- Wt_Info[playerid][wtChannel] = -1;
- SendRangedMessage(playerid, COLOR_ME, stringa, 15.0);
- }
- else
- {
- format(stringa, sizeof(stringa), "%s has left the channel", pName);
- SendClientMessageToChannel(Wt_Info[playerid][wtChannel], COLOR_RED, stringa);
- SendClientMessage(playerid, COLOR_INFO, "[Info]: Did you turn off the Walkie Talkie");
- Wt_Info[playerid][wtOn] = false;
- Wt_Info[playerid][wtChannel] = -1;
- SendRangedMessage(playerid, COLOR_ME, stringa, 15.0);
- }
- }
- case 1:
- {
- if(Wt_Info[playerid][wtOn]!=true)return SendClientMessage(playerid, COLOR_ERROR, "[Error]: {FFFFFF}You must first turn on the Walkie Talkie.");
- ShowPlayerDialog(playerid, DIALOG_WTCH, DIALOG_STYLE_INPUT, "Frequency Selection", "Select a frequency from 0 to 999", "Select", "Cancel");
- }
- case 2:
- {
- if(Wt_Info[playerid][wtOn]!=true)return SendClientMessage(playerid, COLOR_ERROR, "[Error]: {FFFFFF}You must first turn on the Walkie Talkie.");
- PlayerPlaySoundToChannel(Wt_Info[playerid][wtChannel]);
- SendClientMessageToChannel(Wt_Info[playerid][wtChannel], COLOR_WT, "**The Walkie Talkie issued a sound**");
- SetTimerEx("PlayerPlaySoundToChannel", 280, false, "d", Wt_Info[playerid][wtChannel]);
- SetTimerEx("PlayerPlaySoundToChannel", 560, false, "d", Wt_Info[playerid][wtChannel]);
- }
- }
- }
- }
- if(dialogid == DIALOG_WTCH)
- {
- if(response)
- {
- if(strval(inputtext) == Wt_Info[playerid][wtChannel])return SendClientMessage(playerid, COLOR_ERROR, "[Error]: {FFFFFF}You are already in this channel.");
- if(strval(inputtext) < 1 && strval(inputtext) > 999)return SendClientMessage(playerid, COLOR_ERROR, "[Error]: {FFFFFF} Select a frequency from 0 to 999");
- {
- format(stringa, sizeof(stringa), "%s has left the channel", pName);
- SendClientMessageToChannel(Wt_Info[playerid][wtChannel], COLOR_RED, stringa);
- Wt_Info[playerid][wtChannel] = strval(inputtext);
- format(stringa, sizeof(stringa), "%s entered the channel", pName);
- SendClientMessageToChannel(Wt_Info[playerid][wtChannel], COLOR_GREEN, stringa);
- format(stringa, sizeof(stringa), "[WT]: You have entered the channel %d", Wt_Info[playerid][wtChannel]);
- SendClientMessage(playerid, COLOR_GREEN, stringa);
- }
- }
- }
- return 1;
- }
- stock SendRangedMessage(playerid, color, msg[], Float: r)
- {
- new Float: Pos[3], players = GetMaxPlayers();
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- for(new i; i < players; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- if(IsPlayerInRangeOfPoint(i, r, Pos[0], Pos[1], Pos[2])) SendClientMessage(i, color, msg);
- }
- return 1;
- }
- stock SendClientMessageToChannel(channel, color, message[])
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(channel == -1)return 0;
- if(Wt_Info[i][wtChannel] == channel)SendClientMessage(i, color, message);
- }
- return 1;
- }
- public StopUseWalkieTalkie(playerid)
- {
- SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
- return 1;
- }
- public PlayerPlaySoundToChannel(channel)
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(!IsPlayerConnected(i))continue;
- if(channel == -1)return 0;
- if(Wt_Info[i][wtChannel] == channel) PlayerPlaySound(i, 1139, 0, 0 ,0);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement