Jump to content
  • 0
fusqueta

How to execute a simple query in source

Question

I'v beem working on pc.cpp and I want to store death log into db

when I try

            if (SQL_ERROR == Sql_Query(sql_handle, "Insert into death_log(char_id,killer_type,killer_id,map,time,lasthit) values(%d,'%s',%d,%d,'%s',%d)",150000,"BL_PC",150004,1,"20031020",1))
                Sql_ShowDebug(sql_handle);


Error    C2065    'sql_handle': identifier not defined    map-server    D:\rathena\src\map\pc.cpp    8498    
 

how setup db connection from pc.cpp ,skills.cpp ,stats.cpp etc and execute simple querys?   "Insert into 'test'(testint) values (1)"

Edited by fusqueta

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • -1

I created a function on log.cpp that already have all mysql pre-configs needed

 


 

void log_death(int charid, int16 m, int16 killertype, int killerid, int lasthit)

{

StringBuf_Init(&buf);
    StringBuf_Printf(&buf, "%s INTO `%s` ( `map`, `time`)", LOG_QUERY, "death_log");

    StringBuf_Printf(&buf, "values ('%s',NOW() )", map_getmapdata(m)->name[0] ? map_getmapdata(m)->name : "");

    if (SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf)) || SQL_SUCCESS != SqlStmt_Execute(stmt))
        SqlStmt_ShowDebug(stmt);

}

 

Edited by fusqueta

Share this post


Link to post
Share on other sites
  • 0

just use script

OnPCDieEvent:

sql query

end;

Share this post


Link to post
Share on other sites
  • 0

ty for the answer, unfortunately I need to query from source

Edited by fusqueta

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.