PDA

View Full Version : /n(ewbie) problem


cotyzor
23/11/2011, 01:30 PM
if(strcmp(cmd, "/newbchat", true) == 0 || strcmp(cmd, "/n", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}

result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "Utilizare: (/n)ewbchat [text]");
return 1;
}
if(PlayerInfo[playerid][pLevel] > 3 && PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1)
{
SendClientMessage(playerid, COLOR_RED, "Ai level prea mare sa mai poti vorbi in newbie chat!");
return 1;
}
if ((nooon) && PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_GRAD2, " The Newbie channel has been disabled by an Admin !");
return 1;
}

if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}

if(PlayerInfo[playerid][pMuted] == 1)
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, " You can't speak, you have been silenced !");
return 1;
}
if(gNewb[playerid] == 1)
{
PlayerInfo[playerid][pNewbTimer] = 12;
if (PlayerInfo[playerid][pAdmin] == 1)
format(string, sizeof(string), "Admin Level 1: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 2)
format(string, sizeof(string), "Admin Level 2: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 3)
format(string, sizeof(string), "Admin Level 3: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 4)
format(string, sizeof(string), "Admin Level 4: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 5)
format(string, sizeof(string), "Admin Level 5: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 6)
format(string, sizeof(string), "Admin Level 6: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 11)
format(string, sizeof(string), "Fondator: %s[%d]: %s", sendername, playerid ,result);
else if(PlayerInfo[playerid][pLevel] == 1)
format(string, sizeof(string), "Newbie Level 1: %s[%d]: %s", sendername, playerid , result);
else if(PlayerInfo[playerid][pLevel] == 2)
format(string, sizeof(string), "Newbie Level 2: %s[%d]: %s", sendername, playerid , result);
else if(PlayerInfo[playerid][pLevel] == 3)
format(string, sizeof(string), "Newbie Level 3: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 1)
format(string, sizeof(string), "Helper Level 1: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 2)
format(string, sizeof(string), "Helper Level 2: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 3)
format(string, sizeof(string), "Helper Level 3: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 4)
format(string, sizeof(string), "Helper Level 4: %s[%d]: %s", sendername, playerid , result);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[playerid][pLevel] <= 3 || PlayerInfo[playerid][pAdmin] > 0 || PlayerInfo[playerid][pHelper] > 0 || gNewb[i] == 1)
{
SendClientMessage(playerid, 0x9D9D4F96, string);
ntimer[playerid] = 60;
}
}
}
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " The /(n)ewbie has disable");
return 1;
}
}
return 1;
}


Why a message appears 3 times in a row ?

System64
23/11/2011, 01:32 PM
format(string, sizeof(string), "Admin Level 2: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 3)
format(string, sizeof(string), "Admin Level 3: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 4)
format(string, sizeof(string), "Admin Level 4: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 5)
format(string, sizeof(string), "Admin Level 5: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 6)
format(string, sizeof(string), "Admin Level 6: %s[%d]: %s", sendername, playerid ,result);
if (PlayerInfo[playerid][pAdmin] == 11) must be else if!

cotyzor
23/11/2011, 01:54 PM
if(strcmp(cmd, "/newbchat", true) == 0 || strcmp(cmd, "/n", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}

result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "Utilizare: (/n)ewbchat [text]");
return 1;
}
if(PlayerInfo[playerid][pLevel] > 3 && PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1)
{
SendClientMessage(playerid, COLOR_RED, "Ai level prea mare sa mai poti vorbi in newbie chat!");
return 1;
}
if ((nooon) && PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_GRAD2, " The Newbie channel has been disabled by an Admin !");
return 1;
}

if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}

if(PlayerInfo[playerid][pMuted] == 1)
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, " You can't speak, you have been silenced !");
return 1;
}
if(gNewb[playerid] == 1)
{
PlayerInfo[playerid][pNewbTimer] = 12;
if (PlayerInfo[playerid][pAdmin] == 1)
format(string, sizeof(string), "Admin Level 1: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 2)
format(string, sizeof(string), "Admin Level 2: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 3)
format(string, sizeof(string), "Admin Level 3: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 4)
format(string, sizeof(string), "Admin Level 4: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 5)
format(string, sizeof(string), "Admin Level 5: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 6)
format(string, sizeof(string), "Admin Level 6: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 11)
format(string, sizeof(string), "Fondator: %s[%d]: %s", sendername, playerid ,result);
else if(PlayerInfo[playerid][pLevel] == 1)
format(string, sizeof(string), "Newbie Level 1: %s[%d]: %s", sendername, playerid , result);
else if(PlayerInfo[playerid][pLevel] == 2)
format(string, sizeof(string), "Newbie Level 2: %s[%d]: %s", sendername, playerid , result);
else if(PlayerInfo[playerid][pLevel] == 3)
format(string, sizeof(string), "Newbie Level 3: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 1)
format(string, sizeof(string), "Helper Level 1: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 2)
format(string, sizeof(string), "Helper Level 2: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 3)
format(string, sizeof(string), "Helper Level 3: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 4)
format(string, sizeof(string), "Helper Level 4: %s[%d]: %s", sendername, playerid , result);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[playerid][pLevel] <= 3 || PlayerInfo[playerid][pAdmin] > 0 || PlayerInfo[playerid][pHelper] > 0 || gNewb[i] == 1)
{
SendClientMessage(playerid, 0x9D9D4F96, string);
ntimer[playerid] = 60;
}
}
}
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " The /(n)ewbie has disable");
return 1;
}
}
return 1;
}

Now it's oky ?

Pharrel
23/11/2011, 01:55 PM
if(strcmp(cmd, "/newbchat", true) == 0 || strcmp(cmd, "/n", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}

result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "Utilizare: (/n)ewbchat [text]");
return 1;
}
if(PlayerInfo[playerid][pLevel] > 3 && PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1)
{
SendClientMessage(playerid, COLOR_RED, "Ai level prea mare sa mai poti vorbi in newbie chat!");
return 1;
}
if ((nooon) && PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_GRAD2, " The Newbie channel has been disabled by an Admin !");
return 1;
}

if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}

if(PlayerInfo[playerid][pMuted] == 1)
{
SendClientMessage(playerid, TEAM_CYAN_COLOR, " You can't speak, you have been silenced !");
return 1;
}
if(gNewb[playerid] == 1)
{
PlayerInfo[playerid][pNewbTimer] = 12;
if (PlayerInfo[playerid][pAdmin] == 1)
format(string, sizeof(string), "Admin Level 1: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 2)
format(string, sizeof(string), "Admin Level 2: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 3)
format(string, sizeof(string), "Admin Level 3: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 4)
format(string, sizeof(string), "Admin Level 4: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 5)
format(string, sizeof(string), "Admin Level 5: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 6)
format(string, sizeof(string), "Admin Level 6: %s[%d]: %s", sendername, playerid ,result);
else if (PlayerInfo[playerid][pAdmin] == 11)
format(string, sizeof(string), "Fondator: %s[%d]: %s", sendername, playerid ,result);
else if(PlayerInfo[playerid][pLevel] == 1)
format(string, sizeof(string), "Newbie Level 1: %s[%d]: %s", sendername, playerid , result);
else if(PlayerInfo[playerid][pLevel] == 2)
format(string, sizeof(string), "Newbie Level 2: %s[%d]: %s", sendername, playerid , result);
else if(PlayerInfo[playerid][pLevel] == 3)
format(string, sizeof(string), "Newbie Level 3: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 1)
format(string, sizeof(string), "Helper Level 1: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 2)
format(string, sizeof(string), "Helper Level 2: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 3)
format(string, sizeof(string), "Helper Level 3: %s[%d]: %s", sendername, playerid , result);
else if (PlayerInfo[playerid][pHelper] == 4)
format(string, sizeof(string), "Helper Level 4: %s[%d]: %s", sendername, playerid , result);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pLevel] <= 3 || PlayerInfo[i][pAdmin] > 0 || PlayerInfo[i][pHelper] > 0 || gNewb[i] == 1)
{
SendClientMessage(i, 0x9D9D4F96, string);
ntimer[playerid] = 60;
}
}
}
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " The /(n)ewbie has disable");
return 1;
}
}
return 1;
}

Try this way.

cotyzor
24/11/2011, 07:51 PM
@Pharrel: Thanks for help !!!

Now works !