format making function return 0?
#1

so there is a /bug command in which it will create a mysql query and then send that to a mysql database, problem is the format function keeps sending Unknown Command to players. I am using ZCMD, and Gstylezzz mysql plugin. i have tried with his format function and the built in pawn one, here is the code for the command:
pawn Код:
CMD:bug(playerid, params[]) // Will eventually be able to view bugs through an in-game dialog... in theory XD
{
    new FoundID = 0, ID, string[128], model, Float:Angle, pInterior, name[128], pWorld, Float:X, Float:Y, Float:Z, vID, logged[4];
    if(!sscanf(params, "s[128]", name))
    {
        // Get some player stuff
        GetPlayerFacingAngle(playerid, Angle);
        GetPlayerPos(playerid, X, Y, Z);
        pInterior = GetPlayerInterior(playerid);
        pWorld = GetPlayerVirtualWorld(playerid);
        if(IsPlayerInAnyVehicle(playerid))
        {
            vID = GetPlayerVehicleID(playerid);
            model = GetVehicleModel(vID);
        }

        for ( new i = 1; FoundID == 0 ; i++)
        {
            format(string,sizeof(string),"Bugs/%i.ini",i);
            if(!fexist(string))
            {
                ID = i;
                FoundID = 1;
            }
        }
        format(string,sizeof(string),"Bugs/%i.ini",ID);
        new INI:iniFile = INI_Open(string);
        INI_WriteString(iniFile, "Description:", name);
        INI_WriteFloat(iniFile, "X:", X, 3);
        INI_WriteFloat(iniFile, "Y:", Y, 3);
        INI_WriteFloat(iniFile, "Z:", Z, 3);
        INI_WriteFloat(iniFile, "Angle:", Angle, 3);
        INI_WriteInt(iniFile, "Interior:", pInterior);
        INI_WriteInt(iniFile, "World:", pWorld);
        INI_WriteString(iniFile, "Reported by:", GetPlayerNameEx(playerid));
        if(LoggedIn[playerid]) format(logged, sizeof(logged), "yes");
        else format(logged, sizeof(logged), "no");
        INI_WriteString(iniFile, "Logged in?:", logged);
        if(IsPlayerInAnyVehicle(playerid))
        {
            INI_WriteInt(iniFile, "Vehicle ID:", vID);
            INI_WriteInt(iniFile, "Model ID:", model);
            INI_WriteString(iniFile, "Model Name:", GetVehicleName(vID));
        }
        SendClientMessage(playerid, COLOR_RED, "Going to ping the mysql server");
        if(mysql_ping(mysql) != 1) mysql_reconnect(mysql);
        SendClientMessage(playerid, COLOR_RED, "Ping done, creating variable");
        new query[1024];
        SendClientMessage(playerid, COLOR_RED, "Variable Created, formatting Variable");
        format( query, sizeof(query), "INSERT INTO `bugs` (description,posx,posy,posz,angle,interior,world,reporter,logged,vehicleid,modelid,modelname) VALUES ('%s', '%f', '%f', '%f', '%f', '%i', '%i', '%s', '%s', '%i', '%i', '%s')", name, X, Y, Z, Angle, pInterior, pWorld, GetPlayerNameEx(playerid), logged, vID, model, GetVehicleName(vID));
        SendClientMessage(playerid, COLOR_RED, "Variable formatted, sending query");
        mysql_query(query, mysql);
        format(string, sizeof(string), "*Thanks for reporting this issue number %d, it will be reviewed shortly.", ID);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "%s[%d] has reported issue number %d", GetPlayerNameEx(playerid), playerid, ID);
        MessageToAdminsEx( COLOR_WHITE, string); // Created in the admin stock area, currently at the bottom of the script
        INI_Close(iniFile);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "USAGE: /bug [Short description]");
    }
    return 1;
}
if you need more code you can look at the source in my signature, i didnt make the whole command, famalamalam made it and im adapting it to use MySQL.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)