Cop Team Message - 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: Cop Team Message (
/showthread.php?tid=252968)
Cop Team Message -
grand.Theft.Otto - 03.05.2011
I have a /copmessage command for the cops on my server. I am making that command so the cops can talk to each other in it obviously. But my problem is when I type /copmessage (message), the words in the string get messed up and gets the last 8 letters of COP MESSAGE, as it shows in the picture below:
As you can see above, if I type '/copmessage testing', it will show 'pmessage testing', with the pmessage before the starting of 'testing'.
Here is the code:
pawn Код:
if (strcmp("/copmessage", cmdtext, true, 11) == 0)
{
if(strlen(cmdtext) <= 11)
{
SendClientMessage(playerid,red,"USAGE: /copmessage (message) - Enter A Valid Cop Message.");
return 1;
}
else
{
new output[255];
new pname[24];
GetPlayerName(playerid, pname, 24);
strmid(output,cmdtext,3,strlen(cmdtext));
format(string, sizeof(string), "COP MESSAGE: %s(%d) %s",pname,playerid,output);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(Team == TEAM_COPS)
{
format(string, sizeof(string), "COP MESSAGE: %s (%d): %s",pname,playerid,output);
MessageToCops(blue,string);
//SendClientMessage(i,blue,string);
return 1;
}
else
{
if(isnull(cmdtext)) return SendClientMessage(playerid,red,"You Are Not A Cop. You May Not Use The Cop Radio Device.");
SendClientMessage(playerid,red,"You Are Not A Cop. You May Not Use The Cop Radio Device.");
return 1;
}
}
}
}
Here is the stock and forward for MessageToCops:
pawn Код:
forward MessageToCops(color,const string[]);
public MessageToCops(color,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new Team = GetPVarInt(i,"Team");
if(IsPlayerConnected(i) == 1) if(Team==TEAM_COPS) SendClientMessage(i,color,string);
}
return 1;
}
So there is my problem, if anyone knows what I need to add or have done wrong with the code, please let me know.
Re: Cop Team Message -
Joe Staff - 03.05.2011
Your issue is at strmid, set 3 to 12
Re: Cop Team Message -
TheGarfield - 04.05.2011
pawn Код:
forward MessageToCops(color,const string[]);
public MessageToCops(color,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPVarInt(i,"Team") == TEAM_COPS)
{
SendClientMessage(i,color,string);
}
}
}
return 1;
}
Re: Cop Team Message -
grand.Theft.Otto - 04.05.2011
Quote:
Originally Posted by SilentHuntR
Your issue is at strmid, set 3 to 12
|
Wow such an easy thing to miss, thanks a lot.