Emergency services radio - 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: Emergency services radio (
/showthread.php?tid=268352)
Emergency services radio -
McCarthy - 12.07.2011
Whats wrong with this? It breaks my register system
pawn Код:
if(!strcmp(cmdtext, "/e ", true, 3))
{
if (gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_WSPD || gTeam[playerid] == TEAM_FBI || gTeam[playerid] == TEAM_MEDIC || gTeam[playerid] == TEAM_FIREMAN)
{
if(!strlen(cmdtext[3]))
{
SendClientMessage(playerid,COLOR_GREY, "USAGE: /e [text]");
return 1;
}
GetPlayerName(playerid,player,sizeof(player));
format(string,sizeof(string),"*Radio %s(%i):%s, over",player,playerid,cmdtext[2]);
SendCopMessage(COLOR_BLUE, string);
return 1;
}
Re: Emergency services radio -
Lorenc_ - 12.07.2011
Have you tried removing it and rewriting it with efficient includes provided now-a-days?
Strcmp is a really old method when it comes to creating commands, and is not that efficient anymore.
TRY y_cmds or zcmd w/ sscanf.
Re: Emergency services radio -
Basicz - 12.07.2011
I don't know why, but try :
pawn Код:
if ( !strcmp( cmdtext, "/e", true, 2 ) )
{
if ( gTeam[ playerid ] == TEAM_COP || gTeam[ playerid ] == TEAM_WSPD || gTeam[ playerid ] == TEAM_FBI || gTeam[ playerid ] == TEAM_MEDIC || gTeam[ playerid ] == TEAM_FIREMAN )
{
if ( cmdtext[ 2 ] != ' ' || !cmdtext[ 3 ] )
return SendClientMessage( playerid, -1, "{FF0000}USAGE: {AAAAAA}/e [ text ]" );
new
tempName[ 24 ],
tempString[ 128 ]
;
GetPlayerName( playerid, tempName, sizeof ( tempName );
format( tempString, sizeof ( tempString ), "* Radio %s( %i ): %s, over.", tempName, playerid, cmdtext[ 2 ] );
SendCopMessage( COLOR_BLUE, string );
return 1;
}
else return SendClientMessage( playerid, -1, "{FF0000}ERROR: {AAAAAA}You are not in the correct team." );
return 1;
}
Or, somethings wrong with the SendCopMessage function?
pawn Код:
stock SendCopMessage( color, const string[ ] )
{
for ( new j = GetMaxPlayers( ), i; i < j; i ++ )
{
if ( !IsPlayerConnected( i ) )
continue;
if ( gTeam[ i ] == TEAM_COP || gTeam[ i ] == TEAM_WSPD || gTeam[ i ] == TEAM_FBI || gTeam[ i ] == TEAM_MEDIC || gTeam[ i ] == TEAM_FIREMAN )
{
SendClientMessage( i, color, string );
}
}
return 1;
}
EDIT: Just added an example of a "SendCopMessage function".