AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   mysql problem (https://forums.alliedmods.net/showthread.php?t=53957)

CipryXXX 04-14-2007 05:58

mysql problem
 
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")
        }
    }
}


mysticssjgoku4 04-14-2007 08:15

Re: mysql problem
 
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.

CipryXXX 04-14-2007 12:18

Re: mysql problem
 
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.

CipryXXX 04-15-2007 06:56

Re: mysql problem
 
no1 knows why?


All times are GMT -4. The time now is 06:34.

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