SA-MP Forums Archive
Check is the user already own it - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Check is the user already own it (/showthread.php?tid=662805)



Check is the user already own it - DarkMythHunter - 12.01.2019

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.


Re: Check is the user already own it - d3Pedro - 12.01.2019

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;
}



Re: Check is the user already own it - DarkMythHunter - 12.01.2019

Ah got it, worked perfectly. Thanks!

+rep