Looping question. -
Okay, I made that when a player talks in a chat, The animation "Chat" Starts,
Код:
if(strcmp(cmd, "/low", true) == 0 || strcmp(cmd, "/low", true) == 0)
{
if(IsPlayerConnected(playerid))
{
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 cannot speak, you have been silenced");
return 1;
}
new y,m,d;
new h,mi,s;
getdate(y,m,d);
gettime(h,mi,s);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
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, "USAGE: /low [chat text]");
return 1;
}
if(PlayerInfo[playerid][pAdminDuty] == 1)
{
format(string, sizeof(string), "Admin [low]: %s", result);
SetPlayerChatBubble(playerid, string, COLOR_NICERED, 3.0, 8000);
ApplyAnimation(playerid, "PED","IDLE_CHAT",4.0,1,0,0,1,1);
ProxDetector(3.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Admin low): %s",d,m,y,h,mi,s, sendername, result);
ChatLog(string);
}
if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 1)
{
format(string, sizeof(string), "Stranger [low]: %s", result);
SetPlayerChatBubble(playerid, string, COLOR_WHITE, 3.0, 8000);
ApplyAnimation(playerid, "PED","IDLE_CHAT",4.0,1,0,0,1,1);
ProxDetector(3.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (Masked low): %s",d,m,y,h,mi,s, sendername, result);
ChatLog(string);
}
if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
{
format(string, sizeof(string), "%s [low]: %s", sendername, result);
SetPlayerChatBubble(playerid, string, COLOR_WHITE, 3.0, 8000);
ApplyAnimation(playerid, "PED","IDLE_CHAT",4.0,1,0,0,1,1);
ProxDetector(3.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
format(string, sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s (low): %s",d,m,y,h,mi,s, sendername, result);
ChatLog(string);
}
}
return 1;
}
But when he talks in that chat the animation starts without stopping, I want it to start for like 3 or 4 seconds then stops, How?
Re: Looping question. -
Well, if I'm not wrong you have two solutions to your problem. If I'm correct, the thing is that your loop keeps going on for some time. Try doing this:
Solution 1: Instead of that many if if if if one after the other, use "else if" and at the last one use "else"
Solution 2: Try putting a return 1; at each if statement.