/setvip syntaxis
#1

Hey guys, im struggeling with my VIP system, as of now i have the setvip command very simple its as mentioned below, However i wish to save the VIP data in a different table uing [pData][Playerid][ID]
and [pData][playerid][Username], i would like to check using these, however as of now it just saves in my player table, but thats not what i really wanted, i wanted to make a different table for VIP, and also making /setvip [level], granting someone one month of vip, however im not quite sure on how to do so.

In the Vip table it should contain
[ID] [Username] [Viplevel] [Granteddate] [Expirydate] [Active]
something like that,
anyone has any idea on how to realize this?

the setvip command :
Код:
CMD:setvip(playerid, params[])
{
        new lookupid, str[128], level;
        if(pData[playerid][Admin] == 6)
        {

                if(sscanf(params,"ud",lookupid,level)) return SendClientMessage(playerid, COLOR_WHITE, "{ff387a}[Admin]:{ffffff} /setvip [ID | Name] [level]");
                if(pData[lookupid][VIP] > pData[playerid][VIP]) return SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Error]: {ffffff}You are not authorized to use this command.");
                if(level < 1 ||level > 5) return SendClientMessage(playerid, COLOR_WHITE,  "{ff0000}[Error]:{ffffff} You can only set levels 1 to 5.");
                if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Error]{ffffff} This player is not connected.");
                if(level < pData[lookupid][VIP])
                {
                        format(str, sizeof(str), "{ff387a}[Admin]:{ffffff} %s (ID:%d) has demoted you to VIP level %d!",GetName(playerid), playerid, level);
                        SendClientMessage(lookupid, COLOR_WHITE, str);
                        format(str, sizeof(str),"{ff387a}[Admin]:{ffffff} You have demoted %s (ID:%d) to VIP level %d!",GetName(lookupid),lookupid,level);
                        SendClientMessage(playerid, COLOR_WHITE, str);
                        pData[lookupid][VIP] = level;
                        SavePlayerData(lookupid);
                }
                if(level > pData[lookupid][VIP])
                {
                        format(str, sizeof(str), "{ff387a}[Admin]:{ffffff} %s (ID:%d) has promoted you to VIP level %d!",GetName(playerid), playerid, level);
                        SendClientMessage(lookupid, COLOR_WHITE, str);
                        format(str, sizeof(str),"{ff387a}[Admin]:{ffffff} You have promoted %s (ID:%d) to VIP level %d!",GetName(lookupid),lookupid,level);
                        SendClientMessage(playerid, COLOR_WHITE, str);
                        pData[lookupid][VIP] = level;
                        SavePlayerData(lookupid);
                }
        }
        else return SendClientMessage(playerid, COLOR_WHITE, "{ff0000}[Error]{ffffff}You are not authorized to use this command.");
        return 1;
}
Reply
#2

I've tried setting up my database using referring keys.
So.. i set it up like this ;
Reply
#3

One way is toto create an enumerator with all the variables related to vip.
BUT, as vince one mentioned to me for a question i had related to a house system he told me that.
Quote:

Username should only appear once in the database. While it is technically possible to set up a foreign key relation with a text type field, it is discouraged to do so because string comparison is obviously much slower than integer comparison. Especially for varchar fields where length is not fixed.

Connect 2 different tables of your database.. Don't use username everywhere . Create relation views. If this is so difficult then create an enumerator which will have all VIP variables. and instead of using account variables use VIP one.
Reply
#4

I see, but the username is being stored for myself so i can easily overview current vips in my ACP,
They will not be identified by username tho, but by ID.
Reply
#5

Show me SavePlayerData(lookupid) function
Reply
#6

Код:
stock SavePlayerData(playerid)
{
        new query[512];
        mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%i, `VIP`=%i, `EXPE`=%i, `Kills`=%d, `Deaths`=%d, `Score`=%d, `Wanted`=%d, `Money`=%d, `Job`=%d, `Copban`=%d, `Armyban`=%d, WHERE `ID`=%d",
        IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][EXPE], pData[playerid][Kills], pData[playerid][Deaths], GetPlayerScore(playerid), GetPlayerWantedLevel(playerid), pData[playerid][Money], pData[playerid][Job], pData[playerid][Copban], pData[playerid][Armyban], pData[playerid][ID]);
        mysql_tquery(mysql, query, "", "");
}
Reply
#7

Explain me something because i can't understand the table due to language you have database named players and inside it a VIP table?
Reply
#8

I have a database called ''sampdb'' in there, i have 3 tables, players - vip - vehicles.
Reply
#9

to update stats on vip table you have to use "UPDATE `vip`" not `UPDATE `players`
Reply
#10

you asked me for a different function lol.

At the moment i have the viplevel stored in the player table, not in the vip table.
Thats what i need help with, i need to shape the setvip command to fit with the vip table.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)