Jump to content
  • 0

How to execute a simple query in source


fusqueta

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  32
  • Reputation:   0
  • Joined:  10/26/20
  • Last Seen:  

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
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • -1

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  32
  • Reputation:   0
  • Joined:  10/26/20
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.01
  • Content Count:  398
  • Reputation:   246
  • Joined:  07/04/19
  • Last Seen:  

just use script

OnPCDieEvent:

sql query

end;

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  32
  • Reputation:   0
  • Joined:  10/26/20
  • Last Seen:  

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

Edited by fusqueta
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  32
  • Reputation:   0
  • Joined:  10/26/20
  • Last Seen:  

UP

Link to comment
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...