Zcmd String Issue
#1

Hey,

Im trying to get what the player says,

Example: Inputtex,CommandText,

This is what I have for my Radio Code and its not working, Its displaying everything but what the player has said,

pawn Код:
COMMAND:r(playerid,params)
{
new UnitIdentifier[512];
new cmdtext[100];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
UnitIdentifier = dini_Get("UnitIDs.txt",playername);
new erpstring[128];
if(PlayerTeam[playerid] == Team_Sheriff || PlayerTeam[playerid] == Team_LVPD || PlayerTeam[playerid] == Team_Fire){
if(dini_Exists("UnitIDs.txt")){
if(strlen(dini_Get("UnitIDs.txt",playername))!=0) {
GetPlayerName(playerid, playername, sizeof(playername));
format(erpstring, sizeof(erpstring), "(DCPCOM) %s %d: %s, over.", UnitIdentifier, playerid,cmdtext[3] );
SendMessageToLaw(erpstring);
}else{
GetPlayerName(playerid, playername, sizeof(playername));
format(erpstring, sizeof(erpstring), "(DCPCOM) Unit %d: %s, over.", playerid, cmdtext[3]);
SendMessageToLaw(erpstring);
SendClientMessage(playerid,COLOR_YELLOW,erpstring);
}
}
}
return 1;
}
Reply
#2

Indentation. ****** it.

Change cmdtext[3] to params.
Reply
#3

Small problem with that:



Uploaded with ImageShack.us
Reply
#4

I suggest you use sscanf to make things easier, you're already using zcmd
Reply
#5

Yeah and seriously learn at least one form of indentation that looks a mess and makes me not even want to look through it.
Reply
#6

Luckily I was on a caffeinie buzz.
What you did wrong was create an empty variable called "cmdtext" then use it. The variable called "params" contains the command string except for the first part.
I think this should work:

pawn Код:
COMMAND:r( playerid, params )
{
    if ( isnull( params ) )
    {
        SendClientMessage( playerid, -1, "USAGE: /r [text]" );
       
        return 1;
    }
   
    new
        UnitIdentifier[ 512 ],
        playername[ MAX_PLAYER_NAME ]
    ;
   
    GetPlayerName( playerid, playername, sizeof( playername ) );
   
    UnitIdentifier = dini_Get( "UnitIDs.txt", playername );
   
    new erpstring[ 128 ];
   
    if ( PlayerTeam[ playerid ] == Team_Sheriff || PlayerTeam[ playerid ] == Team_LVPD || PlayerTeam[ playerid ] == Team_Fire )
    {
        if ( dini_Exists( "UnitIDs.txt" ) )
        {
            if ( strlen( dini_Get( "UnitIDs.txt", playername ) ) != 0 )
            {
                GetPlayerName( playerid, playername, sizeof( playername ) );
               
                format( erpstring, sizeof( erpstring ), "(DCPCOM) %s %d: %s, over.", UnitIdentifier, playerid, params );
               
                SendMessageToLaw( erpstring );
            }
            else
            {
                GetPlayerName( playerid, playername, sizeof( playername ) );
               
                format( erpstring, sizeof( erpstring ), "(DCPCOM) Unit %d: %s, over.", playerid, params );
               
                SendMessageToLaw( erpstring );
               
                SendClientMessage( playerid, COLOR_YELLOW, erpstring );
            }
        }
    }
   
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)