SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/05/2013, 07:25 PM   #1
zT KiNgKoNg
Gangsta
 
Join Date: Jun 2012
Location: $Location = $this->Location->Finder('United Kingdom');
Posts: 911
Reputation: 40
Default Account Check [Donator]

I've just started my donator system and i've made it so it checks if the player is vip or not when they spawn, If they're vip it then checks the expiration date and removes them from the donators list after the 30 days has gone, But if they're still vip with lets say 25 days left i wan't it to show they've got 25 days left and i've coded it that way but for some reason it isn't showing up.

Let me add, Its inserting into the database table correctly with the correct date and expiration date.


Code:
pawn Code:
- OnPlayerSpawn -

CheckAccountDonator(playerid);

 -Checking -

stock CheckAccountDonator(playerid)
{
    new bExpiration;

    format(Query, sizeof(Query), "SELECT * FROM `Donators` WHERE (Username = '%s') AND status = 1", GetPName(playerid), GetIP(playerid));
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() >= 1)
    {
        while(mysql_fetch_row_format(Query,"|"))
        {
            mysql_fetch_field_row(Query, "Expiration"); bExpiration = strval(Query);

            if(bExpiration > 0)
            {
                if(gettime() >= bExpiration)
                {
                    format(Query, sizeof(Query), "DELETE FROM `Donators` WHERE Username = %s", GetPName(playerid));
                    mysql_query(Query);
                    SendClientMessage(playerid,-1,"Your time as a Donator has run out and you've been removed from donator status");
                    pData[playerid][DonatorLevel] = 0;
                }
                else
                {
                    new string[100];
                    format(string, sizeof(string),"Welcome Back, %s you've got %d days level as a donator",(bExpiration-gettime())/2592000);
                    SendClientMessage(playerid,-1,string);
                }
            }
        }
        return 1;
    }
    return 0;
}
zT KiNgKoNg is offline   Reply With Quote
Old 20/05/2013, 12:26 PM   #2
zT KiNgKoNg
Gangsta
 
Join Date: Jun 2012
Location: $Location = $this->Location->Finder('United Kingdom');
Posts: 911
Reputation: 40
Default Re: Account Check [Donator]

Highly needed, Any help would be great.
zT KiNgKoNg is offline   Reply With Quote
Old 21/05/2013, 04:05 PM   #3
zT KiNgKoNg
Gangsta
 
Join Date: Jun 2012
Location: $Location = $this->Location->Finder('United Kingdom');
Posts: 911
Reputation: 40
Default Re: Account Check [Donator]

Still Needed [Major]
zT KiNgKoNg is offline   Reply With Quote
Old 23/05/2013, 02:44 PM   #4
zT KiNgKoNg
Gangsta
 
Join Date: Jun 2012
Location: $Location = $this->Location->Finder('United Kingdom');
Posts: 911
Reputation: 40
Default Re: Account Check [Donator]

Still needed.
zT KiNgKoNg is offline   Reply With Quote
Old 23/05/2013, 03:37 PM   #5
MiGu3X
Huge Clucker
 
Join Date: Jan 2013
Posts: 223
Reputation: 6
Default Re: Account Check [Donator]

Ill later chec the error also use %i instead of %d ... Its a number (integer) ..
MiGu3X is offline   Reply With Quote
Old 23/05/2013, 03:50 PM   #6
SuperViper
High-roller
 
SuperViper's Avatar
 
Join Date: Sep 2011
Posts: 1,178
Reputation: 315
Default Re: Account Check [Donator]

Firstly, wrap your values in MySQL queries with ' '.

pawn Code:
DELETE FROM `Donators` WHERE Username = '%s'

Secondly, you forgot to specify the player's name as an arguement in format.

pawn Code:
format(string, sizeof(string),"Welcome Back, %s you've got %d days level as a donator", GetPName(playerid), (bExpiration-gettime())/2592000);

Thirdly, 2592000 is a month in seconds and 86400 is a day.
__________________
Release NameUse
FairPlayKeep the cheaters out of your server
Object Model ArrayArray of every single object model in the game
RCON PanelControl any server as you like with RCON controls
SlopeClimb up a steep hill against other players with cars falling down

I do not play on any SAMP server. Anyone with the name Ricky Phelps in-game is an imposter.
SuperViper is offline   Reply With Quote
Old 23/05/2013, 03:52 PM   #7
Scenario
Godfather
 
Scenario's Avatar
 
Join Date: Feb 2010
Location: Heaven
Posts: 7,809
Reputation: 701
Default Re: Account Check [Donator]

Your query was wrong, and so was the way you were loading the information. mysql_fetch_row_format() would be used if you were planning to split the data with sscanf, or, as the name suggests, the "split" function.

Also, on your SendClientMessage line you listed a %s and a %d. You didn't fill in any variable to replace the %s with, so it made the time your %s and %d was nothing.

pawn Code:
stock CheckAccountDonator(playerid)
{
    new bExpiration;

    format(Query, sizeof(Query), "SELECT * FROM `Donators` WHERE Username = '%s' AND status = 1", GetPName(playerid), GetIP(playerid));
    mysql_query(Query);
   
    mysql_store_result();
    if(mysql_num_rows() >= 1)
    {
        while(mysql_fetch_row())
        {
            mysql_fetch_field_row(Query, "Expiration"); bExpiration = strval(Query);

            if(bExpiration > 0)
            {
                if(gettime() >= bExpiration)
                {
                    format(Query, sizeof(Query), "DELETE FROM `Donators` WHERE Username = %s", GetPName(playerid));
                    mysql_query(Query);
                    SendClientMessage(playerid,-1,"Your time as a Donator has run out and you've been removed from donator status");
                    pData[playerid][DonatorLevel] = 0;
                }
                else
                {
                    new string[100];
                    format(string, sizeof(string),"Welcome Back, %s you've got %d days level as a donator",(bExpiration-gettime())/2592000);
                    SendClientMessage(playerid,-1,string);
                }
            }
        }
    }
    mysql_free_result(); // you need to be calling this!
    return 0;
}
Furthermore, MiGu3X, you're wrong. %d and %i are basically the same thing.
Scenario is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[MySQL] Check Account not quite working Kontrol Scripting Help 7 17/01/2013 07:49 PM
Donator status Fernado Samuel Scripting Help 1 17/01/2013 08:37 AM
Donator - Features? 'Pawno. General 9 25/09/2012 07:19 PM
Donator thomas.. Help Archive 7 13/09/2010 03:48 PM


All times are GMT. The time now is 11:07 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.