Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Sa-Mp Include SendTimeMessage
- *
- * (c) by Kaliber, 2013
- *
- */
- #include <a_samp>
- #if defined k_tm
- #endinput
- #endif
- #define k_tm
- #if !defined MAX_ARGS
- #define MAX_ARGS 10
- #endif
- #define INVALID_ID MAX_ARGS+1
- #if !defined MAX_STRING
- #define MAX_STRING 64
- #endif
- static TM_String[MAX_PLAYERS][MAX_ARGS][MAX_STRING],TM_AllString[MAX_ARGS][MAX_STRING];
- forward bool:TM_Timer(playerid,color,time,x);
- forward bool:TM_TimerAll(color,time,x);
- forward OnLocalMessageSend(playerid,text[]);
- forward OnGlobalMessageSend(text[]);
- public bool:TM_TimerAll(color,time,x) {
- if(!TM_AllString[x-1][0]) x = INVALID_ID;
- switch(x) {
- case 0: return false;
- case INVALID_ID: { x = 0; ClearMemoryAll(); return true; }
- }
- if(!CallRemoteFunction("OnGlobalMessageSend","s",TM_AllString[x-1])) {
- print("Cleard !"); x = 0; ClearMemoryAll(); return true;
- }
- SendClientMessageToAll(color,TM_AllString[x-1]);
- x++;
- SetTimerEx("TM_TimerAll",time*1000,0,"dddd",color,time,x);
- return true;
- }
- public bool:TM_Timer(playerid,color,time,x) {
- if(!IsPlayerConnected(playerid)) x = INVALID_ID;
- if(!TM_String[playerid][x-1][0]) x = INVALID_ID;
- switch(x) {
- case 0: return false;
- case INVALID_ID: { x = 0; ClearMemory(playerid); return true; }
- }
- if(!CallRemoteFunction("OnLocalMessageSend","is",playerid,TM_String[playerid][x-1])) {
- x = 0;
- ClearMemory(playerid);
- return true;
- }
- SendClientMessage(playerid,color,TM_String[playerid][x-1]);
- x++;
- SetTimerEx("TM_Timer",time*1000,0,"dddd",playerid,color,time,x);
- return true;
- }
- stock bool:SendTimeMessage(...) {
- new s=0,playerid = getarg(0,0),color = getarg(1,0),time=getarg(2,0),buffer[MAX_ARGS+3][MAX_STRING],num=numargs();
- for(new n=3; n<num; n++) {
- for(new i; i<MAX_STRING; i++) if((buffer[n][i] = getarg(n,i)) == '\0') break;
- }
- for(new i; i<MAX_ARGS; i++) {
- s = i+3;
- format(TM_String[playerid][i],MAX_STRING,buffer[s]);
- }
- TM_Timer(playerid,color,time,1);
- return true;
- }
- stock bool:SendTimeMessageToAll(...) {
- new s=0,color = getarg(0,0),time=getarg(1,0),buffer[MAX_ARGS+2][MAX_STRING],num=numargs();
- for(new n=2; n<num; n++) {
- for(new i; i<MAX_STRING; i++) if((buffer[n][i] = getarg(n,i)) == '\0') break;
- }
- for(new i; i<MAX_ARGS; i++) {
- s = i+2;
- format(TM_AllString[i],MAX_STRING,buffer[s]);
- }
- TM_TimerAll(color,time,1);
- return true;
- }
- stock ClearMemoryAll() {
- for(new i; i<MAX_ARGS; i++) strdel(TM_AllString[i],0,strlen(TM_AllString[i]));
- }
- stock ClearMemory(playerid) {
- for(new i; i<MAX_ARGS; i++) strdel(TM_String[playerid][i],0,strlen(TM_String[playerid][i]));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement