Well, I haven't used strmid much so I'm a bit inexperienced with it. Anyways, when I type a message that's longer than 128 characters, instead of continuing the text in the next line, it repeats the last part of the part1.
pawn Код:
if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pFaction] != 255 && (DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1 || DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 2 || DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 3))
{
if(PlayerInfo[playerid][pRank] != 1 && PlayerInfo[playerid][pRank] != 2 && PlayerInfo[playerid][pRank] != 3)
{
SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] Only the top three ranks can use this command.");
return 1;
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[256];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_USAGE, "[USAGE:] /(gov)ernment [text]");
return 1;
}
if(PlayerInfo[playerid][pRank] == 1)
{
if(strlen(result)<129)
{
new faction = PlayerInfo[playerid][pFaction];
format(string, sizeof(string), "[Government:] %s %s: %s", DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid), result);
SendClientMessageToAll(COLOR_POLICE, string);
}
else
{
new part1[54];
new part2[74];
strmid(part1,result,0,128,128);
new faction = PlayerInfo[playerid][pFaction];
format(string, sizeof(string), "[Government:] %s %s: %s", DynamicFactions[faction][fRank1],GetPlayerNameEx(playerid), part1);
SendClientMessageToAll(COLOR_POLICE, string);
strmid(part2,result,129,256,127);
format(string, sizeof(string), "...%s",part2);
SendClientMessageToAll(COLOR_POLICE, string);
}
}
if(PlayerInfo[playerid][pRank] == 2)
{
if(strlen(result)<54)
{
new faction = PlayerInfo[playerid][pFaction];
format(string, sizeof(string), "[Government:] %s %s: %s", DynamicFactions[faction][fRank2],GetPlayerNameEx(playerid), result);
SendClientMessageToAll(COLOR_POLICE, string);
}
else
{
new part1[54];
new part2[74];
strmid(part1,result,0,54,54);
new faction = PlayerInfo[playerid][pFaction];
format(string, sizeof(string), "[Government:] %s %s: %s", DynamicFactions[faction][fRank2],GetPlayerNameEx(playerid), result);
SendClientMessageToAll(COLOR_POLICE, string);
strmid(part2,result,55,128,74);
format(string, sizeof(string), "...%s",part2);
SendClientMessageToAll(COLOR_POLICE, string);
}
}
if(PlayerInfo[playerid][pRank] == 3)
{
if(strlen(result)<54)
{
new faction = PlayerInfo[playerid][pFaction];
format(string, sizeof(string), "[Government:] %s %s: %s", DynamicFactions[faction][fRank3],GetPlayerNameEx(playerid), result);
SendClientMessageToAll(COLOR_POLICE, string);
}
else
{
new part1[54];
new part2[74];
strmid(part1,result,0,54,54);
new faction = PlayerInfo[playerid][pFaction];
format(string, sizeof(string), "[Government:] %s %s: %s", DynamicFactions[faction][fRank3],GetPlayerNameEx(playerid), result);
SendClientMessageToAll(COLOR_POLICE, string);
strmid(part2,result,55,128,74);
format(string, sizeof(string), "...%s",part2);
SendClientMessageToAll(COLOR_POLICE, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_ORANGE, "[ERROR:] You're not in a valid faction.");
}
}
return 1;
}
Код:
if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsACop(playerid) || IsANG(playerid) || PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4 || PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6)
{
if(PlayerInfo[playerid][pMember] == 1)
{
if(PlayerInfo[playerid][pRank] < 4)
{
SendClientMessage(playerid, COLOR_GREY, " You need to be Rank 4 to be able to use this !");
return 1;
}
}
else
{
if(PlayerInfo[playerid][pRank] < 5)
{
SendClientMessage(playerid, COLOR_GREY, " You need to be Rank 5 to be able to use this !");
return 1;
}
}
GetPlayerNameEx(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: (/gov)ernment [text]");
return 1;
}
new rtext[64];
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1) //LSPD
{
if(PlayerInfo[playerid][pRank] == 4) { rtext = "LSPD Captain"; }
else if(PlayerInfo[playerid][pRank] == 5) { rtext = "LSPD Deputy Chief"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "LSPD Chief"; }
}
else if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2) //FBI
{
if(PlayerInfo[playerid][pRank] == 5) { rtext = "FBI Assistant Director"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "FBI Director"; }
}
else if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3) //SASP
{
if(PlayerInfo[playerid][pRank] == 5) { rtext = "Superintendent"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "Commodore"; }
}
else if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4) //Paramedic
{
if(PlayerInfo[playerid][pRank] == 5) { rtext = "LSFMD Captain"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "LSFMD Battalion Chief"; }
}
else if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5) //National Guard
{
if(PlayerInfo[playerid][pRank] == 5) { rtext = "NG Colonel"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "NG General"; }
}
else if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6) //Senate
{
if(PlayerInfo[playerid][pRank] == 5) { rtext = "Vice Governor"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "Governor"; }
}
else if(PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7) //CIA
{
if(PlayerInfo[playerid][pRank] == 5) { rtext = "SS Vice Director"; }
else if(PlayerInfo[playerid][pRank] == 6) { rtext = "SS Director"; }
}
SendClientMessageToAll(COLOR_WHITE, "|___________ Government News Announcement ___________|");
format(string, sizeof(string), "%s %s: %s",rtext,sendername, result);
SendClientMessageToAll(COLOR_DBLUE, string);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not a Cop / FBI / Fireman / Paramedic / NG / Governor !");
}
}
return 1;
}
Try to use this i use it and it works perfect.. Give me a rep if i helped you.