Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ********************************
- SFS - Simple Friend Sys.
- ********************************
- Descrição:
- Permite interagir com amigos de um servidor.
- Versão:
- 1.0
- Developer:
- Luke "Larceny" G.
- "Lós" .
- ChangeLOG:
- 17/09/2011:
- Primeira versão.
- Thanks To:
- ZeeX - ZCMD Command Processor.
- Y_Less - Efficient and Powerful sscanf & foreach.
- Double-O-Seven - DOF2 Fast INI file system.
- Protioso - PSF include.
- SA-MP Team - For All.
- */
- #define FILTERSCRIPT
- #define AMIGODIALOG 9876
- #define MESGEDIALOG 9877
- #include <a_samp>
- #include <zcmd>
- #include <DOF2>
- #include <sscanf2>
- #include <foreach>
- #include <PSF>
- new Text:BackGround;
- new Text:TextString[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
- new Text:ListString[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
- new StringTimer[MAX_PLAYERS];
- new FriendTimer[MAX_PLAYERS];
- forward HideMessageBoxForPlayer(playerid);
- forward HideFriendBoxForPlayer(playerid);
- forward SetMessageBoxForPlayer(playerid, string[]);
- forward SetFriendBoxForPlayer(playerid, string[]);
- stock GetPlayerNameEx(playerid)
- {
- new string[MAX_PLAYER_NAME];
- GetPlayerName(playerid, string, MAX_PLAYER_NAME);
- return string;
- }
- stock GetPlayerNameIns(playerid)
- {
- new string[MAX_PLAYER_NAME];
- GetPlayerName(playerid, string, MAX_PLAYER_NAME);
- new stringLength = strlen(string);
- strins(string, "~n~", stringLength);
- return string;
- }
- public OnFilterScriptInit()
- {
- print("\n-------------------------------------------");
- print("Simple Friend System carregado com sucesso.");
- print("-------------------------------------------\n");
- //
- BackGround = TextDrawCreate(640.000000, 336.000000, "_");
- TextDrawBackgroundColor(BackGround, 255);
- TextDrawFont(BackGround, 1);
- TextDrawLetterSize(BackGround, 0.600000, 12.000000);
- TextDrawColor(BackGround, -1);
- TextDrawSetOutline(BackGround, 0);
- TextDrawSetProportional(BackGround, 1);
- TextDrawSetShadow(BackGround, 1);
- TextDrawUseBox(BackGround, 1);
- TextDrawBoxColor(BackGround, 119);
- TextDrawTextSize(BackGround, 480.000000, 0.000000);
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- public SetMessageBoxForPlayer(playerid, string[])
- {
- KillTimer(StringTimer[playerid]);
- TextDrawSetString(TextString[playerid], string);
- TextDrawShowForPlayer(playerid, BackGround);
- TextDrawShowForPlayer(playerid, TextString[playerid]);
- return 1;
- }
- public SetFriendBoxForPlayer(playerid, string[])
- {
- KillTimer(FriendTimer[playerid]);
- TextDrawSetString(ListString[playerid], string);
- TextDrawShowForPlayer(playerid, ListString[playerid]);
- return 1;
- }
- public HideFriendBoxForPlayer(playerid)
- {
- KillTimer(FriendTimer[playerid]);
- TextDrawHideForPlayer(playerid, ListString[playerid]);
- return 1;
- }
- public HideMessageBoxForPlayer(playerid)
- {
- KillTimer(StringTimer[playerid]);
- TextDrawHideForPlayer(playerid, BackGround);
- TextDrawHideForPlayer(playerid, TextString[playerid]);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- TextString[playerid] = TextDrawCreate(483.000000, 337.000000, "Bem Vindo:");
- TextDrawBackgroundColor(TextString[playerid], 255);
- TextDrawFont(TextString[playerid], 1);
- TextDrawLetterSize(TextString[playerid], 0.210000, 1.400000);
- TextDrawColor(TextString[playerid], -1);
- TextDrawSetOutline(TextString[playerid], 0);
- TextDrawSetProportional(TextString[playerid], 1);
- TextDrawSetShadow(TextString[playerid], 1);
- TextDrawUseBox(TextString[playerid], 1);
- TextDrawBoxColor(TextString[playerid], 0xFFFFFF00);
- TextDrawTextSize(TextString[playerid], 638.000000, 0.000000);
- //
- ListString[playerid] = TextDrawCreate(156.000000, 165.000000, "Amigos Online:");
- TextDrawBackgroundColor(ListString[playerid], 255);
- TextDrawFont(ListString[playerid], 1);
- TextDrawLetterSize(ListString[playerid], 0.410000, 0.799999);
- TextDrawColor(ListString[playerid], -1);
- TextDrawSetOutline(ListString[playerid], 0);
- TextDrawSetProportional(ListString[playerid], 1);
- TextDrawSetShadow(ListString[playerid], 1);
- TextDrawUseBox(ListString[playerid], 1);
- TextDrawBoxColor(ListString[playerid], 119);
- TextDrawTextSize(ListString[playerid], 390.000000, 20.000000);
- //
- new USER_FILE[64], AmigosOnline;
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- if(!DOF2_FileExists(USER_FILE)) DOF2_CreateFile(USER_FILE);
- foreach(Player, i)
- {
- if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(i)) == 1)
- {
- AmigosOnline++;
- new iStr[50];
- format(iStr, sizeof(iStr), "~n~~n~%s conectou-se.", GetPlayerNameEx(playerid));
- SetMessageBoxForPlayer(i, iStr);
- StringTimer[i] = SetTimerEx("HideMessageBoxForPlayer", 6000, false, "i", i);
- }
- }
- //
- new iStr[128];
- format(iStr, sizeof(iStr), "Bem-vindo %s,~n~~n~Conectado com sucesso.~n~~n~Amigos Online: %i", GetPlayerNameEx(playerid), AmigosOnline);
- TextDrawSetString(TextString[playerid], iStr);
- TextDrawShowForPlayer(playerid, BackGround);
- TextDrawShowForPlayer(playerid, TextString[playerid]);
- StringTimer[playerid] = SetTimerEx("HideMessageBoxForPlayer", 6000, false, "i", playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- TextDrawDestroy(Text:TextString[playerid]);
- TextDrawDestroy(Text:ListString[playerid]);
- TextString[playerid] = Text:INVALID_TEXT_DRAW;
- ListString[playerid] = Text:INVALID_TEXT_DRAW;
- new USER_FILE[64];
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- foreach(Player, i)
- {
- if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(i)) == 1)
- {
- new iStr[50];
- format(iStr, sizeof(iStr), "~n~~n~%s desconectou-se.", GetPlayerNameEx(playerid));
- SetMessageBoxForPlayer(i, iStr);
- StringTimer[i] = SetTimerEx("HideMessageBoxForPlayer", 6000, false, "i", i);
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case AMIGODIALOG:
- {
- if(!response)
- {
- SendClientMessage(GetPVarInt(playerid, "AmigoRequest"), 0x33AA33AA, "(*) Ele recusou o convite.");
- DeletePVar(playerid, "AmigoRequest");
- SendClientMessage(playerid, 0x33AA33AA, "(*) Você recusou o convite.");
- return 1;
- }
- new USER_FILE[64], FRIEND_FILE[64];
- new giveplayerid = GetPVarInt(playerid, "AmigoRequest");
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- DOF2_SetInt(USER_FILE, GetPlayerNameEx(giveplayerid), 1);
- format(FRIEND_FILE, sizeof(FRIEND_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(giveplayerid));
- DOF2_SetInt(FRIEND_FILE, GetPlayerNameEx(playerid), 1);
- SendClientMessage(giveplayerid, 0x33AA33AA, "(*) Ele aceitou o convite.");
- SendClientMessage(playerid, 0x33AA33AA, "(*) Você aceitou o convite.");
- DeletePVar(playerid, "AmigoRequest");
- }
- case MESGEDIALOG:
- {
- if(!response) return 1;
- new command[128];
- format(command, sizeof(command), "%i %s", GetPVarInt(playerid, "ClickedPlayer"), inputtext);
- cmd_msn(playerid, command);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- new USER_FILE[64];
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(clickedplayerid)) == 0) return SendClientMessage(playerid, 0x33AA33AA, "(*) Você não é amigo deste jogador.");
- SetPVarInt(playerid, "ClickedPlayer", clickedplayerid);
- ShowPlayerDialog(playerid, MESGEDIALOG, DIALOG_STYLE_INPUT, "Enviando mensagem para amigo.", "Digite a mensagem.", "Enviar", "Cancelar");
- return 1;
- }
- CMD:amigo(playerid, params[])
- {
- new giveplayerid;
- if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0x33AA33AA, "(*) /amigo [playerid]");
- if(playerid == giveplayerid) return SendClientMessage(playerid, 0x33AA33AA, "(*) Você não pode ser amigo de você mesmo.");
- new USER_FILE[64];
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(giveplayerid)) == 1) return SendClientMessage(playerid, 0x33AA33AA, "(*) Você já é amigo deste jogador.");
- new iStr[70];
- format(iStr, sizeof(iStr), "(*) Você enviou um convite a %s para serem amigos.", GetPlayerNameEx(giveplayerid));
- SendClientMessage(playerid, 0x33AA33AA, iStr);
- format(iStr, sizeof(iStr), "%s deseja se tornar seu amigo.\nVocê aceita?", GetPlayerNameEx(playerid));
- ShowPlayerDialog(giveplayerid, AMIGODIALOG, DIALOG_STYLE_MSGBOX, "Deseja ser meu amigo?", iStr, "Sim", "Não");
- SetPVarInt(giveplayerid, "AmigoRequest", playerid);
- return 1;
- }
- CMD:deletaramigo(playerid, params[])
- {
- new giveplayerid;
- if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0x33AA33AA, "(*) /deletaramigo [playerid]");
- if(playerid == giveplayerid) return SendClientMessage(playerid, 0x33AA33AA, "(*) Você não pode deletar você mesmo.");
- new USER_FILE[64];
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(giveplayerid)) != 1) return SendClientMessage(playerid, 0x33AA33AA, "(*) Você não é amigo deste jogador.");
- new iStr[70];
- format(iStr, sizeof(iStr), "(*) Você deletou %s de seus amigos.", GetPlayerNameEx(giveplayerid));
- SendClientMessage(playerid, 0x33AA33AA, iStr);
- format(iStr, sizeof(iStr), "%s deletou você como amigo.", GetPlayerNameEx(playerid));
- SendClientMessage(giveplayerid, 0x33AA33AA, iStr);
- DOF2_SetInt(USER_FILE, GetPlayerNameEx(giveplayerid), 0);
- //
- new FRIEND_FILE[64];
- format(FRIEND_FILE, sizeof(FRIEND_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(giveplayerid));
- DOF2_SetInt(FRIEND_FILE, GetPlayerNameEx(playerid), 0);
- return 1;
- }
- CMD:meusamigos(playerid, params[])
- {
- new count = 0;
- new iStr[1024] = "Amigos Online:~n~";
- foreach(Player, i)
- {
- new USER_FILE[64];
- format(USER_FILE, sizeof(USER_FILE), "SFSUsers /%s.ini", GetPlayerNameEx(playerid));
- if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(i)) == 1)
- {
- strins(iStr, GetPlayerNameIns(i), strlen(iStr));
- count++;
- }
- }
- if(count == 0)
- {
- SetFriendBoxForPlayer(playerid, "Amigos Online:~n~Nenhum amigo online.");
- FriendTimer[playerid] = SetTimerEx("HideFriendBoxForPlayer", 6000, false, "i", playerid);
- }
- else
- {
- SetFriendBoxForPlayer(playerid, iStr);
- FriendTimer[playerid] = SetTimerEx("HideFriendBoxForPlayer", 6000, false, "i", playerid);
- }
- return 1;
- }
- CMD:creditosfs(playerid, params[])
- {
- SendClientMessage(playerid, 0xA9C4E4FF, "Simple Friend System - Credits");
- SendClientMessage(playerid, 0xA9C4E4FF, "Delevelopers:");
- SendClientMessage(playerid, 0x33AA33AA, "Luke ''Larceny'' G.");
- SendClientMessage(playerid, 0x33AA33AA, "Los.");
- return 1;
- }
- CMD:ajudafs(playerid, params[])
- {
- SendClientMessage(playerid, 0xA9C4E4FF, "Comandos:");
- SendClientMessage(playerid, 0xA9C4E4FF, "/amigo(convidar um amigo) - /deletaramigo - /msn(enviar mensagem[ou clicar tab]) - /creditosfs - /ajudafs - /meusamigos(ver amigos online)");
- return 1;
- }
- CMD:msn(playerid, params[])
- {
- new giveplayerid, gMsg[128];
- if(sscanf(params, "us[128]", giveplayerid, gMsg)) return SendClientMessage(playerid, 0x33AA33AA, "(*) /msn [playerid] [mensagem]");
- if(playerid == giveplayerid) return SendClientMessage(playerid, 0x33AA33AA, "(*) Você não pode enviar mensagens para você mesmo.");
- if(strcmp(gMsg,"^",true) == 0) return SendClientMessage(playerid, 0x33AA33AA, "(*) ''^'' não é um caractere permitido.");
- if(strcmp(gMsg,"~",true) == 0) return SendClientMessage(playerid, 0x33AA33AA, "(*) ''~'' não é um caractere permitido.");
- new iStr[256], gStr[164];
- format(iStr, sizeof(iStr), "%s diz: ~n~%s", GetPlayerNameEx(playerid), gMsg);
- format(gStr, sizeof(gStr), "%s diz: %s", GetPlayerNameEx(playerid), gMsg);
- iStr = psf_FormatarStrTexto(iStr);
- SetMessageBoxForPlayer(giveplayerid, iStr);
- StringTimer[giveplayerid] = SetTimerEx("HideMessageBoxForPlayer", 6000, false, "i", giveplayerid);
- SendClientMessage(giveplayerid, -1, gStr);
- //
- format(iStr, sizeof(iStr), "para %s: ~n~%s", GetPlayerNameEx(giveplayerid), gMsg);
- format(gStr, sizeof(gStr), "para %s: %s", GetPlayerNameEx(giveplayerid), gMsg);
- iStr = psf_FormatarStrTexto(iStr);
- SetMessageBoxForPlayer(playerid, iStr);
- StringTimer[playerid] = SetTimerEx("HideMessageBoxForPlayer", 6000, false, "i", playerid);
- SendClientMessage(playerid, -1, gStr);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement