script code /n chat - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: script code /n chat (
/showthread.php?tid=242847)
script code /n chat -
ConsoleX - 20.03.2011
I have this script that is currently on my server it's for /n but everyone can abuse it by spamming without waiting 50 seconds
This is my code:
Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
if(PlayerInfo[playerid][pTut] == 0)
{
Kick(playerid);
return 1;
}
if((nonewbie) && PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GREY, " The Newbie channel has been disabled by an Admin !");
return 1;
}
if(PlayerInfo[playerid][pNewbieMuted] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " You are banned from speaking in that channel !");
return 1;
}
if(UseNewbieTimer[playerid] && HelperDuty[playerid]) return SendClientMessage(playerid,COLOR_GREY," You must wait 50 seconds before speaking in that channel !");
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[96];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/n)ewbie [newbie chat]");
return 1;
}
if(PlayerInfo[playerid][pLevel] > 1 && PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 0) format(string, sizeof(string), "** Player %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 2) format(string, sizeof(string), "** Admin %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] >= 2) format(string, sizeof(string), "** Head Helper %s: %s", sendername, result);
else if(PlayerInfo[playerid][pDonateRank] >= 1) format(string, sizeof(string), "** VIP ** %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] == 1) format(string, sizeof(string), "** Helper %s: %s", sendername, result);
else format(string, sizeof(string), "** Newbie %s: %s", sendername, result);
OOCNewbie(NEWBIE_COLOR,string);
if(PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 1) { UseNewbieTimer[playerid] = true; SetTimerEx("UseNewbie",50*1000,0,"i",playerid); }
}
}
I would like to have it as
Newbies - 60 second wait time to use /n after each use
Players - 50 seconds wait time when using /n after each use
Helpers - No wait time no seconds minutes anything
Since newbie and players are abusing it, have to mute everyone sort of like a lawless city.
Re: script code /n chat -
maramizo - 20.03.2011
SetTimer.
AW: script code /n chat -
Pablo Borsellino - 20.03.2011
A simple Code without any timers
At the top of your Script:
pawn Код:
AntiNewbieChatSpam[MAX_PLAYERS];
The command:
pawn Код:
if(strcmp(cmd, "/newbie", true) == 0 || strcmp(cmd, "/n", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(GetTickCount()-AntiNewbieChatSpam[playerid])<60000)
{
SendClientMessage(playerid, COLOR_GREY, " Wait 60 Seconds, to write again in this Chat!");
return 1;
}
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
if(PlayerInfo[playerid][pTut] == 0)
{
Kick(playerid);
return 1;
}
if((nonewbie) && PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GREY, " The Newbie channel has been disabled by an Admin !");
return 1;
}
if(PlayerInfo[playerid][pNewbieMuted] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " You are banned from speaking in that channel !");
return 1;
}
if(UseNewbieTimer[playerid] && HelperDuty[playerid]) return SendClientMessage(playerid,COLOR_GREY," You must wait 50 seconds before speaking in that channel !");
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[96];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/n)ewbie [newbie chat]");
return 1;
}
if(PlayerInfo[playerid][pLevel] > 1 && PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 0) format(string, sizeof(string), "** Player %s: %s", sendername, result);
else if(PlayerInfo[playerid][pAdmin] >= 2) format(string, sizeof(string), "** Admin %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] >= 2) format(string, sizeof(string), "** Head Helper %s: %s", sendername, result);
else if(PlayerInfo[playerid][pDonateRank] >= 1) format(string, sizeof(string), "** VIP ** %s: %s", sendername, result);
else if(PlayerInfo[playerid][pHelper] == 1) format(string, sizeof(string), "** Helper %s: %s", sendername, result);
else format(string, sizeof(string), "** Newbie %s: %s", sendername, result);
OOCNewbie(NEWBIE_COLOR,string);
AntiNewbieChatSpam[playerid]==GetTickCount();
if(PlayerInfo[playerid][pAdmin] <= 1 && PlayerInfo[playerid][pHelper] <= 1) { UseNewbieTimer[playerid] = true; SetTimerEx("UseNewbie",50*1000,0,"i",playerid); }
}
}
Re: script code /n chat -
ConsoleX - 20.03.2011
No, not an anti spam timer then that would make everyone wait haha
anyone have a settimer code?
AW: script code /n chat -
Pablo Borsellino - 20.03.2011
Its not an anti Spam timer? So everyone can only write every 60 Seconds in the newbie Chat
Re: script code /n chat -
ConsoleX - 21.03.2011
Not bad, but what about admins, helpers? would they wait.
Re: script code /n chat -
ConsoleX - 21.03.2011
that that keep admins/helpers from using the chat without wait time
Re: script code /n chat -
Roomeo - 21.03.2011
Pm? They Can Pm
Re: script code /n chat -
Davz*|*Criss - 21.03.2011
Roomeo you banned? For.