Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dutils>
- #include <sscanf>
- #pragma unused ret_memcpy
- #define SendClientFormat(%0,%1,%2,%3,%4) format(%2,sizeof(%2),%3,%4), SendClientMessage(%0,%1,%2)
- /*
- * Don't remove the credits!
- ** Filter Script by RaFaeL - Multi private messages
- *** Version: 0.2 [BETA]
- **** Bags to: [email protected] - Thanks!
- */
- public OnFilterScriptInit()
- {
- print("[RaFaeL] multi Private messages V0.2 - Loaded...!");
- return 1;
- }
- //==============================================================================
- public OnFilterScriptExit()
- {
- print("[RaFaeL] multi Private messages V0.2 - unLoaded...!");
- return 1;
- }
- //==============================================================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], params[256], idx, str[128];
- cmd = strtok(cmdtext, idx); params = strrest(cmdtext, idx);
- //=-=-==-=-=-=-=-=-=-=--=-=-=-=-=--=-=-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- if(!strcmp(cmd, "/Pm", true))
- {
- new ids[64], text[128], sendids[5][5] = {"-1","-1","-1","-1","-1"}, SendedNames[128], SendedCount; //Veribles for the system
- if(sscanf(params, "ss", ids, text)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /Pm [IDs] [Text]"); //Check if command typed correctly
- split(ids, sendids, ',', 5); //Splits the ids -> 1,2,3 will give an array
- for(new i; i<sizeof(sendids); i++) if(strval(sendids[i]) != INVALID_PLAYER_ID && IsPlayerConnected(strval(sendids[i]))/* && strval(sendids[i]) != playerid*/) { //Create a loop to check ids and create names list
- format(str, sizeof(str), "%s%s", GetName(strval(sendids[i])), (i > 0)? (", "):("")), strcat(SendedNames, str); //format the name (add , if need) and add to string
- SendedCount++; //Add one to the names count
- }
- if(SendedCount == 0) return SendClientMessage(playerid, 0xFF0000AA, "Wrong ID/s"); //Check if have at least one id correct
- for(new i; i<sizeof(sendids); i++) { //looping the ids and send the message
- SendClientFormat(strval(sendids[i]), 0x0000FFFF, str, "[PM] %s(To: %s): %s", GetName(playerid), GetName(strval(sendids[i])), text); //send formated message to players
- }
- return SendClientFormat(playerid, 0xEAFF00FF, str, "[PM] %s(To: %s): %s", GetName(playerid), SendedNames, text);//send formated message to player
- }
- //=-=-==-=-=-=-=-=-=-=--=-=-=-=-=--=-=-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- return 0;
- }
- //==============================================================================
- stock split(const strsrc[], strdest[][], delimiter, size = 100)
- {
- new i, li;
- new aNum;
- new len;
- while(i <= strlen(strsrc))
- {
- if(strsrc[i] == delimiter || i == strlen(strsrc))
- {
- len = strmid(strdest[aNum], strsrc, li, i, 128);
- strdest[aNum][len] = 0;
- li = i+1;
- aNum++;
- }
- if(aNum == size) break;
- i++;
- }
- return 1;
- }
- stock strrest(const string[], index)
- {
- new length = strlen(string),offset = index,result[256];
- while((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index - offset] = string[index],index++;
- result[index - offset] = EOS;
- if(result[0] == ' ' && string[0] != ' ') strdel(result,0,1);
- return result;
- }
- stock GetName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement