24.11.2013, 18:10
So,I downloaded InfinityCOD's anti-advertising filterscript but added the stuff from the filterscript in my gamemode.I changed some stuff to make the kick message appear for kicked player,but for some reason the message appear 4 times insteaf of only 1 time.Anyone have any idea what could be the problem ? Thx in advance.Here is my OnPlayerText stuff:
I was thinking if the time in the timer is too much,but its not the reason I think,because when I use the same way in /ban and /kick cmds,the message appears only 1 time.
Код:
public OnPlayerText(playerid, text[]) { new Name[24], Msg[256]; new is1=0; new r=0; while(strlen(text[is1])) { if('0'<=text[is1]<='9') { new is2=is1+1; new p=0; while(p==0) { if('0'<=text[is2]<='9'&&strlen(text[is2])) is2++; else { strmid(strR[r],text,is1,is2,255); if(strval(strR[r])<255) r++; is1=is2; p=1; } } } is1++; } if(r>=4) { new strMy[255]; new STRname[255]; GetPlayerName(playerid,STRname,255); format(strMy, sizeof(strMy), "Suspicion advertising by %s(%d) (text: %s)",STRname,playerid,text); for(new j1=0; j1 < MAX_PLAYERS;j1++) if(APlayerData[j1][PlayerLevel] > 0) SendClientMessage(j1, 0xFF0000FF, strMy); printf("[ADVERT]Suspicion advertising by %s (text: %s)",STRname,text); for(new z=0;z<r;z++) { new pr2; while((pr2=strfind(text,strR[z],true))!=-1) for(new i=pr2,j=pr2+strlen(strR[z]);i<j;i++) text[i]='*'; SendClientMessage(playerid,0xff0000ff,"You have been kicked for advertising attempt"); format(strMy,255,"%s has been kicked for advertising attempt",STRname); SendClientMessageToAllEx(playerid,0xff0000ff,strMy); SetTimerEx("AdvertKick", 1000, false, "i", playerid); } } else if(GPS_Spawned[playerid] == 1) { // Block the player's text if he has been muted if (APlayerData[playerid][Muted] == false) { if(Channel[playerid] != 19) { for (new i; i < MAX_PLAYERS; i++) { if(Channel[i] == Channel[playerid]) { if(text[0] == '*' && Channel[playerid]!= 19) { SendPlayerMessageToAll(playerid, text[1]); } else { GetPlayerName(playerid, Name, sizeof(Name)); format(Msg, 256, "[CB %i] %s: %s", Channel[playerid], Name, text); SendClientMessage(i, 0xabcdefFF, Msg); } } } } else SendPlayerMessageToAll(playerid, text); } else // Let the player know he's still muted SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You are still muted"); } else SendClientMessage(playerid, 0xffffffff, "{FF0000}Error: You are not spawned."); return 0; } forward AdvertKick(playerid); public AdvertKick(playerid) { Kick(playerid); return 1; }