Raised This Month: $32 Target: $400
 8% 

MySQL commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 07-28-2011 , 12:46   MySQL commands
Reply With Quote #1

Hey,

I would like to get some help with creating 2 MySQL commands.

1) When a player wants to see a XP ranking I would like them to type /classrank and then a Motd will pop up, simmilar to the /top15
In here you will get the following tables :
Code:
Rank (1-15) | Name | Class | level
I got this code in HTML, but since the database doesn't support remote acces I can only use it on the gameserver. (This is the HTML version http://faithless.ukgamers.com/Diablo%20Rank.php )

2) Also I would like to have a set xp command as admin. This would update the database based on steam id. Currently Currently the xp that players get is saved by the following method.
Code:
new q_command[512]
                format(q_command,511,"UPDATE `%s` SET `nick`='%s',`ip`='%s', `lvl`='%i',`exp`='%i',`str`='%i',`int`='%i',`dex`='%i',`agi`='%i' WHERE `sid`='%s' AND `klasa`='%i' ",g_sqlTable,name,ip,player_lvl[id],player_xp[id],player_strength[id],player_intelligence[id],player_dextery[id],player_agility[id],sid,player_class[id])
I would greatly appriciate it if the command would be like amx_setxp autid, class (counts from 1-8 since its diablo mod so would be player_class[id] == 1-8, xp (the amount of experience I want to set it to)
Example: amx_setxp faithless 8 73700

I would greatly appriciate ANY help I could get on this!

Thanks in advance!

Last edited by egbertjan; 07-28-2011 at 13:26.
egbertjan is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 08-01-2011 , 15:40   Re: MySQL commands
Reply With Quote #2

from PM

Code:
public updatexp(id) 
{     
    new ip[64] 
    new sid[64]         
    get_user_ip(id, ip ,63,1)     
    get_user_authid(id, sid ,63)                  
    new q_command[512]     

    format(q_command,511,"UPDATE `%s` SET `lvl`='%i',`exp`='%i' WHERE `sid`='%s' AND `klasa`='%i' ",g_sqlTable,player_lvl[id],player_xp[id],sid,player_class[id])    
    SQL_ThreadQuery(g_SqlTuple,"Save_xp_handle",q_command)
}
whats 'klasa' ? if klasa has another value than in the mysql db, nothing will happen.

Something from a plugin of me u could use for making a modt,
you just need to change some values.

Code:
public GeneratePlayerUpgrades(id, iPlayer)
{
    new szTemp[1024], szName[32];
    new iLen = 0;
    
    get_user_name(iPlayer, szName, charsmax(szName));
    
    iLen = format(szTemp, charsmax(szTemp), "<body bgcolor=#000000><font color=#FFB000><pre>");
    iLen += format(szTemp[iLen], charsmax(szTemp) - iLen, "<font color=#00FF00><center><h1>Point System: Upgrades from %s</h1></center></font>^n^n", szName);
    
    for(new i; i < iMaxUpgradeItems; i++)
    {
        iLen += format(szTemp[iLen], charsmax(szTemp) - iLen, "%s %s - Level: %i^n", szUpgradeItems[i], szUpgradeItemType[i], iUpgradeLevel[id][i]); // you would mainly need to edit here.
    }
    
    show_motd(id, szTemp, "Upgrades");
}
So if a player disconnects, you make him save the xp.
Why don't you use that function for the command you want?
__________________
I am out of order!

Last edited by grimvh2; 08-01-2011 at 15:45.
grimvh2 is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-01-2011 , 15:48   Re: MySQL commands
Reply With Quote #3

klasa is the class, I've had to translate the whole Diablo mod from Polish to English, but I forgot to translate the SQL format. After some time I decided to keep it this way.

Anyway I also wanted to merge an existing xpgiving command:
Code:
public CmdGiveXp(id, iCid, iLvl)
{
    if(!cmd_access(id, iLvl, iCid, 3))
    return PLUGIN_HANDLED;
    
    new name[32]
    new szPlayer[32], szAmount[10];
    read_argv(1, szPlayer, charsmax(szPlayer));
    read_argv(2, szAmount, charsmax(szAmount));
    get_user_name(id, name, 31)
    new iPlayer = cmd_target(id, szPlayer, CMDTARGET_ALLOW_SELF);
    new iAmount = str_to_num(szAmount);
    
    if(!iPlayer)
    return PLUGIN_HANDLED;
    
    Give_Xp(iPlayer, iAmount);
    new szName[32];
    get_user_name(iPlayer, szName, charsmax(szName));
    
    console_print(id, "* Gave %i xp to %s", iAmount, szName);
    log_to_file("addons/amxmodx/logs/diablo.log","%s Gave %i xp to %s",name, iAmount, szName)
    return PLUGIN_HANDLED;
}
If I were to type the following command db_givexp egbertjan (name), 40(level), 7670(experience), 8 (classid)
egbertjan is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-01-2011 , 16:04   Re: MySQL commands
Reply With Quote #4

Quote:
Originally Posted by grimvh2 View Post
So if a player disconnects, you make him save the xp.
Why don't you use that function for the command you want?
Because I am not quite sure if it's written correctly if I would modify this. I don't want to mess around with the saving methods, I rather get it done good from the start

Also the classranking would have to be read from the MySQL aswell. here it has to select the playername (as table name: name), Class (as table name: klasa), Level (as table name lvl).

Last edited by egbertjan; 08-01-2011 at 16:16.
egbertjan is offline
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

Forum Jump


All times are GMT -4. The time now is 01:37.


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