Raised This Month: $ Target: $400
 0% 

[Help] MySQL & PHP


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-30-2016 , 12:05   Re: [Help] MySQL & PHP
Reply With Quote #11

Try my above code. I did not test it.

Just so you know, the player will not get the php entered golds until a map change is done. If you want it real-time, you will need to requery the database when you need the data.
__________________

Last edited by Bugsy; 01-30-2016 at 12:07.
Bugsy is offline
Croxeye
Member
Join Date: Jul 2015
Old 01-30-2016 , 14:28   Re: [Help] MySQL & PHP
Reply With Quote #12

Thanks Bugsy.. All works fine
Croxeye is offline
Croxeye
Member
Join Date: Jul 2015
Old 01-30-2016 , 18:47   Re: [Help] MySQL & PHP
Reply With Quote #13

But when I want to buy something in gold shop, my golds are not removed (item price).
Croxeye is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-30-2016 , 19:36   Re: [Help] MySQL & PHP
Reply With Quote #14

You can use this. It will return true if the person had enough money, and false if not. It will pull gold out of current first and then total.
PHP Code:
public PayGoldid iAmount )
{
    new 
blnSuccess true;
    
    if ( 
gGoldsid ][ pgCurrent ] >= iAmount )
    {
        
gGoldsid ][ pgCurrent ] -= iAmount;
    }
    else if ( 
gGoldsid ][ pgTotal ] >= iAmount )
    {
        
gGoldsid ][ pgTotal ] -= iAmount;
    }
    else if ( ( 
gGoldsid ][ pgCurrent ] + gGoldsid ][ pgTotal ] ) >= iAmount )
    {
        
gGoldsid ][ pgCurrent ] -= iAmount;
        
gGoldsid ][ pgTotal ] -= absgGoldsid ][ pgCurrent ] );
        
gGoldsid ][ pgCurrent ] = 0;
    }
    else
    {
        
blnSuccess false;
    }
    
    return 
blnSuccess;

__________________
Bugsy is offline
Croxeye
Member
Join Date: Jul 2015
Old 01-30-2016 , 19:43   Re: [Help] MySQL & PHP
Reply With Quote #15

OK thx Bugsy I will test it.

How to make something like amx_reloadadmins just for this plugin. When I kill some1, I get +1 gold in database automaticly without changing map or rr server. And same from the other side, When I add golds from php page to database, I get that golds in server without changing map or rr server.
Croxeye is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-30-2016 , 19:46   Re: [Help] MySQL & PHP
Reply With Quote #16

You would need to query the database before the person makes a purchase or you want to display their gold in chat or whatever.
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-30-2016 , 19:50   Re: [Help] MySQL & PHP
Reply With Quote #17

But this is only an issue when the player is in-game when they get gold via the PHP. Will this ever happen?
__________________
Bugsy is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 07:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode