This command takes quite long to get to params..
#1

What I mean is, if I am at the location and I type the command..... It takes like 8 seconds for the SSCANF part to display, i'm not sure why?

pawn Код:
CMD:buycoke(playerid, params[])
{
    if(LoggedIn[playerid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(!IsPlayerInRangeOfPoint(playerid,5.0,246.3822,1434.9996,23.3750)) return SendClientMessage(playerid, COLOUR_GREY, "You are not at the cocaine buying position.");
    PlayerLevel[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "Level", "accounts");
    if(PlayerLevel[playerid] < 2) return SendClientMessage(playerid, COLOUR_GREY, "You must be at least level 2 to purchase weed.");
    new amount, sum, money;
    if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /buycoke [grams] ($450 per gram.)");


    sum = Cocaine[playerid] + amount;

    Cocaine[playerid] = sum;

    GivePlayerMoney(playerid, -amount*250);

    money = amount*450;
   
    PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
    MySQL_SetInteger(PlayerSQLID[playerid], "Cocaine", Cocaine[playerid], "accounts");
   
    MySQL_SetInteger(PlayerSQLID[playerid], "Money", PlayerMoney[playerid] - money, "accounts");

    new string[128];
    format(string, sizeof(string), "You have purchased %d grams of cocaine, it cost $%d, you now have %d grams of cocaine", amount, money, sum);
    SendClientMessage(playerid, COLOUR_WHITE, string);
    return 1;
}
Reply
#2

Lag.
Reply
#3

No, this is the only command it does it for... Also, Can you tell me how I can search for part of a name from something like this:

Example if I searched "Grant" How could I get EVERY result from that with "Grant"?
pawn Код:
CMD:findnumber(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(Phonebook[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You do not have a phonebook, you can buy one from a store.");
    new player[24],string[128], query[256];
    if(sscanf(params, "s[24]",player)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /findnumber [player name]");
   
   
    format(query, sizeof(query), "SELECT `Number` FROM `accounts` WHERE `PlayerName` = '%s'", player);
    mysql_query(query); // No query line
    mysql_store_result(); // "Error nothing to store"
    new rows = mysql_num_rows();
    new msnum = mysql_fetch_int();
    if(rows > 0)
        {
            format(string, sizeof(string), "%s - %d", player, msnum);
            SendClientMessage(playerid, COLOUR_WHITE, string);
        }
    if(rows == 0)
        {
            SendClientMessage(playerid, COLOUR_GREY, "There was no numbers found with that name.");
        }
        mysql_free_result();
    return 1;
}
Reply
#4

Show mysql get function
2.
WHERE `PlayerName` LIKE '%s%'", player);
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Show mysql get function
2.
WHERE `PlayerName` LIKE '%s%'", player);
I don't understand?
Reply
#6

MySQL_GetValue is Your own function ? if yes, show

and replace
format(query, sizeof(query), "SELECT `Number` FROM `accounts` WHERE `PlayerName` = '%s'", player);
to
format(query, sizeof(query), "SELECT `Number` FROM `accounts` WHERE `PlayerName` LIKE '%s%'", player); // or %s%%
Reply
#7

pawn Код:
stock MySQL_GetString(sqlid, fieldname[], tablename[])
{
    new query[256];
    format(query, sizeof(query), "SELECT `%s` FROM `%s` WHERE `id` = %d LIMIT 1", fieldname, tablename, sqlid);
    mysql_query(query);
    mysql_store_result();
    new iValue = mysql_fetch_int();
    mysql_free_result();
    return iValue;
}

Im presuming you mean get string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)