SA-MP Forums Archive
Command isn't working - 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: Command isn't working (/showthread.php?tid=262175)



Command isn't working - cloudysky - 16.06.2011

pawn Код:
command(movecoords, playerid, params[])
{
    new coords[128];
    if( sscanf( params, "z", coords) )
    {
        if( PlayerInfo[playerid][Admin] >= 4 )
        {
            SendClientMessage( playerid, COLOUR_ORANGE, "Hint: /movecoords (object)" );
            SendClientMessage( playerid, COLOUR_WHITE, "Fish Location >< Fish Location 2 >< Fish Location 3" );
        }
    }
    else
    {
        if( PlayerInfo[playerid][Admin] >= 4 )
        {
            if(strcmp(coords, "Fish Location", true) == 0 )
            {
                GetPlayerPos( playerid, Fishx, Fishy, Fishz);

                dini_FloatSet( "locations.ini", "Fishx", Fishx);
                dini_FloatSet( "locations.ini", "Fishy", Fishy);
                dini_FloatSet( "locations.ini", "Fishz", Fishz);

                SendClientMessage( playerid, PLAYER, "Fish location moved!" );
            }
            else if(strcmp(coords, "Fish Location 2", true) == 0 )
            {
                GetPlayerPos( playerid, Fish2x, Fish2y, Fish2z);

                dini_FloatSet( "locations.ini", "Fish2x", Fish2x);
                dini_FloatSet( "locations.ini", "Fish2y", Fish2y);
                dini_FloatSet( "locations.ini", "Fish2z", Fish2z);

                SendClientMessage( playerid, PLAYER, "Fish location 2 moved!" );
            }
            else if(strcmp(coords, "Fish Location 3", true) == 0 )
            {
                GetPlayerPos( playerid, Fish3x, Fish3y, Fish3z);

                dini_FloatSet( "locations.ini", "Fish3x", Fish3x);
                dini_FloatSet( "locations.ini", "Fish3y", Fish3y);
                dini_FloatSet( "locations.ini", "Fish3z", Fish3z);

                SendClientMessage( playerid, PLAYER, "Fish location 3 moved!" );
            }
        }
    }
    return 1;
}
In game I type /movecoords but instead of saying SendClientMessage( playerid, COLOUR_ORANGE, "Hint: /movecoords (object)" ); it says Fishing Location Moved. Hmm Please help mwa


Re: Command isn't working - Calgon - 16.06.2011

pawn Код:
if( sscanf( params, "z", coords) )
That code returns true or 1 if sscanf could make sense of it and place the values in to the 'coords' variable, so you need to add an exclamation mark (!) before you use sscanf, so:

pawn Код:
if(!sscanf(params, "z", coords))