Check is the user already own it
#1

So I have a tables name "Storage_tents" with columns "tentID, OwnerID, OwnerName, etc.."

I wanted to make something that will check into the database if the user already own like 5 storage tents, then if they do own, they can't make anymore else.


PHP код:
removed 
I want to add it somewhere here, so when a user tries to save a tent, the query will check if he already own 5, then if he does, it'll not let him save it. Thanks who ever helps me +rep.
Reply
#2

You can do it using cache_get_row_count read the wiki, here's an example

pawn Код:
CMD:yourcommand(playerid, params[])
{
    new query[160+MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, name, sizeof(name));
    mysql_format(handle, query, sizeof(query), "SELECT * FROM `Storage_tents` WHERE `OwnerName` = '%s'", name);
    mysql_tquery(handle, query, "CheckStorageTent", "i", playerid);
    return 1;
}
forward CheckStorageTent(playerid);
public CheckStorageTent(playerid)
{
    if(cache_get_row_count(handle) == 5)
    {
        return SendClientMessage(playerid, -1, "You own 5 tents already!");
    }
    else
    {
        //show player the dialog and the rest of your code here
    }
    return 1;
}
Reply
#3

Ah got it, worked perfectly. Thanks!

+rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)