Set a House address
#1

pawn Код:
command(sethouseaddress, playerid, params[])
{
    new id, address[128];
    if(sscanf(params, "dz", id, address))
    {
        if(AdminLoggedIn[playerid] == 1 && Player[playerid][Adminlevel] >= 6)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /sethouseaddress [id] [address]");
        }
        else
        {
            RemoveTextMessage(playerid);
            TextDrawShowForPlayer(playerid, Text:CantCommand);
            SetTimerEx("RemoveTextMessage", 3500, false, "d", playerid);
        }
    }
    else
    {
        if(AdminLoggedIn[playerid] == 1 && Player[playerid][Adminlevel] >= 6)
        {
            new query[2000];
            format(query, sizeof(query), "SELECT * FROM `Houses` WHERE `hAddress` = '%s'", address);
            mysql_function_query(connectionHandle, query, true, "SetHouseAddressCallback", "zdd", address, id, playerid);
        }
    }
    return 1;
}

public SetHouseAddressCallback(address, houseid, playerid)
{
    new
        rows,
        fields;

    cache_get_data(rows, fields);
    if(rows == 1)
    {
        //SendClientMessage(SavingVehiclePlayerID, WARNRED, "This Vehicle already exists");
        SendClientMessage(playerid, WARNRED, "This address already exists!");
    }
    else if(rows == 0)
    {
        new string[128];
        format(Houses[houseid][hAddress], 128, "%s", address);
        format(string, sizeof(string), "You succesfully renamed house id: %d's address to: %s", houseid, address);
        SCM(playerid, YELLOW, string);
        SaveHouse(houseid);
    }
    else
    {
        //SendClientMessage(SavingVehiclePlayerID, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
        SendClientMessage(playerid, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
    }
    return 1;
}
When I did the command: /sethouseaddress 1 TEST

it said:

Код:
[19:21:17] You succesfully renamed house id: 1's address to: Њ
how to fix it?
Reply
#2

The sscanf 'z' specifier is deprecated, as it probably tells you in the server console. Secondly, 'z' - while deprecated - is specific to sscanf. The MySQL plugin does not recognize it. Use 's'. Thirdly, when passing strings to a function, the function parameters should reflect that.

pawn Код:
public SetHouseAddressCallback(address[], houseid, playerid)
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
The sscanf 'z' specifier is deprecated, as it probably tells you in the server console. Secondly, 'z' - while deprecated - is specific to sscanf. The MySQL plugin does not recognize it. Use 's'. Thirdly, when passing strings to a function, the function parameters should reflect that.

pawn Код:
public SetHouseAddressCallback(address[], houseid, playerid)
Works now, thanks.
REP+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)