Raised This Month: $ Target: $400
 0% 

mysql problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CipryXXX
Junior Member
Join Date: Apr 2007
Location: Romania
Old 04-14-2007 , 05:58   mysql problem
Reply With Quote #1

i am making myself a plugin Vampire vs Werewolf , but for now i just whant to insert ppls name into my mysql data base but when i compile i get some warnings:these warnings are at connection,inserting,selection and dbi_num_rows lines.
Code:
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(54 -- 55) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(56) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(56 -- 57) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(57) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(63) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(69) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(69 -- 70) : warning 213: tag mismatch
/home/groups/amxmodx/tmp3/phpEOtwzw.sma(73) : warning 204: symbol is assigned a value that is never used: "inserting"
here is my plugin code for now
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <dbi>

#define PLUGIN "Vampire vs Werewolf"
#define VERSION "1.0"
#define AUTHOR "CipryXXX"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /menu","Meniu")
}
public Meniu(id)
{
    new menu
    menu = menu_create ("\rVampire vs Werewolf","Meniu2")
    menu_additem(menu,"\wVampire","1",0)
    menu_additem(menu,"\wWerewol","2",0)
    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    menu_display(id,menu,0)
}
public Meniu2(id,menu,item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    else
    {
        new buton[100],nume[100]
        new access, callback
        menu_item_getinfo(menu,item,access,buton,99,nume,99,callback)
        new tasta
        tasta = str_to_num(buton)
        switch (tasta)
        {
            case 1:Vampire(id)
            case 2:
            {
                client_print(id, print_center, "Werewolf FTW")
            }
        }
        
    }
    menu_destroy(menu)
    return PLUGIN_HANDLED
}
public Vampire(id)
{
    new name[100],error[100],connection,selection,inserting
    connection = dbi_connect("localhost", "root", " ", "plugin",error,99)
    get_user_name(id,name,99)
    selection = dbi_query(connection,"SELECT * FROM vampir WHERE Name = '%s'",name)
    if (selection == RESULT_FAILED)
    {
        client_print(id, print_center, "Selection Failed")
    }
    else
    {
        if (dbi_num_rows(selection) >0)
        {
            client_print(id, print_center, "U are already a Vampire")
        }
        else
        {
            inserting = dbi_query(connection,"INSERT INTO vampir(Name,XP,Level) VALUES('%s',0,0)",name)
            client_print(id, print_center, "U have been transformed into a Vampire")
        }
    }
}
CipryXXX is offline
Send a message via Yahoo to CipryXXX
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 04-14-2007 , 08:15   Re: mysql problem
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <dbi> #define PLUGIN "Vampire vs Werewolf" #define VERSION "1.0" #define AUTHOR "CipryXXX" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /menu","Meniu") } public Meniu(id) {     new menu     menu = menu_create ("\rVampire vs Werewolf","Meniu2")     menu_additem(menu,"\wVampire","1",0)     menu_additem(menu,"\wWerewol","2",0)     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)     menu_display(id,menu,0) } public Meniu2(id,menu,item) {     if (item == MENU_EXIT)     {         menu_destroy(menu)         return PLUGIN_HANDLED     }     else     {         new buton[100],nume[100]         new access, callback         menu_item_getinfo(menu,item,access,buton,99,nume,99,callback)         new tasta         tasta = str_to_num(buton)         switch (tasta)         {             case 1:Vampire(id)                 case 2:             {                 client_print(id, print_center, "Werewolf FTW")             }         }             }     menu_destroy(menu)     return PLUGIN_HANDLED } public Vampire(id) {     new error[80]     new Sql:con = dbi_connect("localhost", "root", "", "plugin",error,79)         new name[32]     get_user_name(id,name,99)         new Result:result = dbi_query(con,"SELECT * FROM vampir WHERE Name=^"%s^" ",name)     if (result == RESULT_FAILED)     {         client_print(id, print_center, "Selection Failed!")     }     else     {         if (dbi_num_rows(result) >0)         {             client_print(id, print_center, "You are already a vampire.")         }         else         {             dbi_query(con,"INSERT INTO vampir (Name,XP,Level) VALUES('%s',0,0)",name)             client_print(id, print_center, "You have been transformed into a vampire.")         }     }     dbi_free_result(result)     dbi_close(con)     return PLUGIN_HANDLED }

Try that. Even though I'd recommend using SQLX, and instead of searching and storing their names, store their SteamIDS to prevent multiple accounts.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
CipryXXX
Junior Member
Join Date: Apr 2007
Location: Romania
Old 04-14-2007 , 12:18   Re: mysql problem
Reply With Quote #3

i can compile the plugin but doesent do anything when i type /menu in game,the menu doesent show up...
EDIT : works forgot 2 activate the mysql module but now i got another problem if i select my race: vampire he doesent insert my name into db...doesent do anything...not even a message.

Last edited by CipryXXX; 04-14-2007 at 16:11.
CipryXXX is offline
Send a message via Yahoo to CipryXXX
CipryXXX
Junior Member
Join Date: Apr 2007
Location: Romania
Old 04-15-2007 , 06:56   Re: mysql problem
Reply With Quote #4

no1 knows why?
CipryXXX is offline
Send a message via Yahoo to CipryXXX
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 06:34.


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