Problem with isnull and sscanf, returning unknown command.
#1

I have encountered a bug in my script, in which I cannot seem to come across the solution. It may be simple, but I haven't slept for 24 hours, basically when I type these two commands, it returns as "SERVER: Unknown Command"
pawn Код:
CMD:me(playerid, params[]) // BUGGED
{
    new
        string[128],
        action[100];
    if(sscanf(params, "s[100]", action))
    {
        SendClientMessage(playerid, -1, "USAGE: {FFFFFF}/me [action]");
        return 1;
    }
    else
    {
        format(string, sizeof(string), "* %s %s.",(playerid), action);
        ProxDetector(30, playerid, string, COLOR_PURPLE);
    }
    return 1;
}

CMD:act(playerid, params[]) // BUGGED
{
    new
        string[128],
        action[100];
    if(sscanf(params, "s[100]", action))
    {
        SendClientMessage(playerid, -1, "USAGE: {FFFFFF}/act [action]");
        return 1;
    }
    else
    {
        format(string, sizeof(string), "* %s %s.",(playerid), action);
        ProxDetector(30, playerid, string, COLOR_PURPLE);
    }
    return 1;
}
CMD:pm(playerid,params[]) // BUGGED
{
    new message[128];
    if(sscanf(params, "us[32]", playerid, message))
    {
        return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: {FFFFFF}/pm <playerid> <message>");
    }
    if(!IsPlayerConnected(playerid))
    return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");

    new pmsg[256];
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,Name,sizeof(Name));
    format(pmsg,sizeof(pmsg),"PM from %s(%d): %s",Name,playerid,message);

    new playeridmsg[256];
    new playeridname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playeridname,sizeof(playeridname));
    format(playeridmsg,sizeof(playeridmsg),"PM to %s(%d): %s",playeridname,playerid,message);
    SendClientMessage(playerid, COLOR_YELLOW, pmsg);
    SendClientMessage(playerid, COLOR_YELLOW, playeridmsg);
    return 1;
}
CMD:car(playerid,params[]) // BUGGED
{
    new string[128],idx;
    string = strtok(params, idx);
    if(!strlen(string))
    {
        SendClientMessage(playerid,-1, "USAGE: {FFFFFF}[vehicleid] [color1] [color2]");
        return 1;
    }
    new car = strval(string);
    if(car < 400 || car > 611)
    {
        SendClientMessage(playerid, -1, "  VehicleID: 400-611"); return 1;
    }
    string = strtok(params, idx);
    if(!strlen(string))
    {
        SendClientMessage(playerid, -1, "USAGE: {FFFFFF}/car [Vehicle] [color1] [color2]");
        return 1;
    }
    new color1 = strval(string);
    string = strtok(params, idx);
    if(!strlen(string))
    {
        SendClientMessage(playerid, -1, "USAGE: {FFFFFF}/car [Vehicle] [color1] [color2]");
        return 1;
    }
    new color2 = strval(string);
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X,Y,Z);
    new v = CreateVehicle(car, X+2,Y,Z, 0.0,color1,color2, -1);
    LinkVehicleToInterior(v,GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(v,GetPlayerVirtualWorld(playerid));
    SendClientMessage(playerid, -1, "have fun!");
    return 1;
}
CMD:weapons(playerid, params[]) // BUGGED
{
    if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: {FFFFFF}/weapons [weapon name]");

    if(!strcmp(params,"knuckles",true))
    {
        GivePlayerWeapon(playerid, 1, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself brass knuckles.");
    }
    else if(!strcmp(params,"golfclub",true))
    {
        GivePlayerWeapon(playerid, 2, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself brass knuckles.");
    }
    else if(!strcmp(params,"nitestick",true))
    {
        GivePlayerWeapon(playerid, 3, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a nitestick.");
    }
    else if(!strcmp(params,"knife",true))
    {
        GivePlayerWeapon(playerid, 4, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a knife.");
    }
    else if(!strcmp(params,"bat",true))
    {
        GivePlayerWeapon(playerid, 5, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a baseball bat.");
    }
    else if(!strcmp(params,"shovel",true))
    {
        GivePlayerWeapon(playerid, 6, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a shovel.");
    }
    else if(!strcmp(params,"poolcue",true))
    {
        GivePlayerWeapon(playerid, 7, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a pool cue.");
    }
    else if(!strcmp(params,"katana",true))
    {
        GivePlayerWeapon(playerid, 8, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a katana.");
    }
    else if(!strcmp(params,"chainsaw",true))
    {
        GivePlayerWeapon(playerid, 9, 1);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a chainsaw.");
    }
    else if(!strcmp(params,"grenade",true))
    {
        GivePlayerWeapon(playerid, 16, 50);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself 50 grenades.");
    }
    else if(!strcmp(params,"molotov",true))
    {
        GivePlayerWeapon(playerid, 18, 50);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself 50 molotovs.");
    }
    else if(!strcmp(params,"colt",true))
    {
        GivePlayerWeapon(playerid, 22, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a Colt 45.");
    }
    else if(!strcmp(params,"silencer",true))
    {
        GivePlayerWeapon(playerid, 23, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a silenced pistol.");
    }
    else if(!strcmp(params,"deagle",true))
    {
        GivePlayerWeapon(playerid, 24, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a desert eagle.");
    }
    else if(!strcmp(params,"shotgun",true))
    {
        GivePlayerWeapon(playerid, 25, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a shotgun.");
    }
    else if(!strcmp(params,"sawnoff",true))
    {
        GivePlayerWeapon(playerid, 26, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a sawnoff shotgun.");
    }
    else if(!strcmp(params,"combat",true))
    {
        GivePlayerWeapon(playerid, 27, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a combat shotgun.");
    }
    else if(!strcmp(params,"uzi",true))
    {
        GivePlayerWeapon(playerid, 28, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a mini uzi.");
    }
    else if(!strcmp(params,"mp5",true))
    {
        GivePlayerWeapon(playerid, 29, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself an MP5.");
    }
    else if(!strcmp(params,"ak47",true))
    {
        GivePlayerWeapon(playerid, 30, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a Colt 45.");
    }
    else if(!strcmp(params,"m4",true))
    {
        GivePlayerWeapon(playerid, 31, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself an M4.");
    }
    else if(!strcmp(params,"tec9",true))
    {
        GivePlayerWeapon(playerid, 32, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a Tec-9.");
    }
    else if(!strcmp(params,"rifle",true))
    {
        GivePlayerWeapon(playerid, 33, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a country rifle.");
    }
    else if(!strcmp(params,"sniper",true))
    {
        GivePlayerWeapon(playerid, 34, 9999);
        SendClientMessage(playerid,COLOR_GREY,"SERVER: You have just gave yourself a sniper.");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "Incorrect weapon name, please try again!");
    }
    return 1;
}
Everything else works perfectly. If I am correct, this is only happening with my commands either using sscanf or isnull.
Reply
#2

Try this:
pawn Код:
CMD:me(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /me [action]");
   
    new string[126];
    format(string, sizeof(string), "* %s %s", GetPlayersName(playerid), params);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    return 1;
}
Reply
#3

why im using SetPlayerChatBuble ?
when he/she using /me
example: /me test
the text will appear on the head :O
pawn Код:
CMD:me(playerid, params[])
{
    new string[128];
    new pname[MAX_PLAYER_NAME];
    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "usage: /me [action]");
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "{FFFF00}%s{FFFFFF}: %s", pname, params);
    SetPlayerChatBubble(playerid,string,COLOR_WHITE,60.0,5000);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    return 1;
}
Reply
#4

I will try them, but what about the other commands?
Reply
#5

Anyone? I really need help, these commands are really needed.
Reply
#6

Hello Connor.

Those will work!

PHP код:
CMD:me(playeridparams[])
{
    new
        
string[128],
        
action[100];
    if(
sscanf(params"s[100]"action))
    {
        
SendClientMessage(playerid, -1"USAGE: /me [action]");
        return 
1;
    }
    else
    {
        
format(stringsizeof(string), "* %s %s"GetName(playerid), action);
        
ProxDetector(30playeridstring0xFF80FFC8);
    }
    return 
1;

PHP код:
CMD:pm(playeridparams[])
{
    new 
str[256], str2[256], idName1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(
sscanf(params"us"idstr2))
    {
        
SendClientMessage(playerid0xFFFF00C8"Usage: /pm <id> <message>");
        return 
1;
    }
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid0xFFFF00C8"ERROR: Player not connected");
    if(
playerid == id) return SendClientMessage(playerid0xFFFF00C8"ERROR: You cannot pm yourself!");
    {
        
GetPlayerName(playeridName1sizeof(Name1));
        
GetPlayerName(idName2sizeof(Name2));
        
format(strsizeof(str), "PM To %s(ID %d): %s"Name2idstr2);
        
SendClientMessage(playerid0xFFFF00C8str);
        
format(strsizeof(str), "PM From %s(ID %d): %s"Name1playeridstr2);
        
SendClientMessage(id0xFFFF00C8str);
    }
    return 
1;

Your /act a.k.a /do command is bugged because of /act and /me is using the exactly same code. You cannot make TWO commands with same texts. I didn't fix anything in your /act command. Just saying.


PHP код:
CMD:act(playeridparams[]) // BUGGED
{
    new
        
string[128],
        
action[100];
    if(
sscanf(params"s[100]"action))
    {
        
SendClientMessage(playerid, -1"USAGE: {FFFFFF}/act [action]");
        return 
1;
    }
    else
    {
        
format(stringsizeof(string), "* %s %s.",(playerid), action);
        
ProxDetector(30playeridstringCOLOR_PURPLE);
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)