Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _PMS_included
- #endinput
- #endif
- #define _PMS_included
- #include <dutils>
- #include <sscanf2>
- #if !defined SendClientFormat
- #define SendClientFormat(%0,%1,%2,%3,%4) format(%2,sizeof(%2),%3,%4), SendClientMessage(%0,%1,%2)
- #endif
- forward PMS_OnPlayerCommandText(playerid, cmdtext[]);
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], params[256], idx, str[128];
- cmd = strtok(cmdtext, idx); params = pmstrrest(cmdtext, idx);
- //=-=-==-=-=-=-=-=-=-=--=-=-=-=-=--=-=-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- if(!strcmp(cmd, "/Pm", true))
- {
- new ids[24], text[128], sendids[5], SendedNames[128], SendedCount; //Veribles for the system
- if(sscanf(params, "s[24]s[128]", ids, text)) return OnPlayerSendPrivate(playerid, text, true, -1, SendedNames, 0); //Check if command typed correctly
- sscanf(ids, "p<,>A<i>(-1)[5]", sendids); //Splits the ids -> 1,2,3 will give an array
- for(new i; i<sizeof(sendids); i++) if(sendids[i] != INVALID_PLAYER_ID && IsPlayerConnected(sendids[i]) && sendids[i] != playerid) { //Create a loop to check ids and create names list
- SendedCount++; //Add one to the names count
- new sendid = sendids[i]; //Get the Id
- format(str, sizeof(str), "%s%s", (SendedCount > 1 && i < sizeof(sendids))? (", "):(""), PmGetName(sendid)), strcat(SendedNames, str); //Add the name of the sender to string
- OnPlayerSendPrivate(playerid, text, true, sendid, SendedNames, 2); //Send message to reciveid
- }
- if(SendedCount)
- OnPlayerSendPrivate(playerid, text, true, -1, SendedNames, 3); //Send message to sender
- else
- OnPlayerSendPrivate(playerid, text, true, -1, SendedNames, 1); //Send Error message
- return 1;
- }
- //=-=-==-=-=-=-=-=-=-=--=-=-=-=-=--=-=-=---=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- return 0;
- }
- #if defined _PMS_OnPlayerCommandText
- #undef OnPlayerUpdate
- #else
- #define _PMS_OnPlayerCommandText
- #endif
- #define OnPlayerUpdate PMS_OnPlayerCommandText
- forward OnPlayerSendPrivate(playerid, text[], bool:recived, reciveid, reciving[], status); //Status 0 = error, 1 = error, 2 = send to recive, 3 = send to sender
- stock pmstrrest(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 PmGetName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement