Jump to content
  • 0

little question about sql


WordsUp

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

is this code correct?

- script sql -1,{

OnAgitBreak:

if (query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore)) {

query_sql("update `woe_record` set `id` = `id`+1 where `guild_id` = '"+getcharid(2)+"'",.@ignore);

}

OnAgitEnd :

if (query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore)) {

query_sql("update `woe_record` set `castle_id` = '"+getcastlename(2)+"' where `guild_id` = '"+getcharid(2)+"'",.@ignore);

}

i don't know what .@ignore use i just copy that code somewhere in my files.

}

Edited by WordsUp
Link to comment
Share on other sites

16 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

* query_sql "Query"{,<array>{,<array>{,...}}};

* query_logsql "your MySQL query", <array variable> {,<array variable>, ...};

http://ea.dj-yhn.com/index.php?c=query_sql

.@ignore is the returned values of the select to an array however, since he is only checking if it worked, there's no reason to worry about it...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

thanks for the reply zero but can i ask if this works if i use it? or should i need to change anything for this code to work

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

I dont know if this is going to work. I assume your checking if the .@ignore has a value?

- script sql -1,{

OnAgitBreak:

if (query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore)) {

query_sql("update `woe_record` set `id` = `id`+1 where `guild_id` = '"+getcharid(2)+"'",.@ignore);

}

OnAgitEnd :

if (query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore)) {

query_sql("update `woe_record` set `castle_id` = '"+getcastlename(2)+"' where `guild_id` = '"+getcharid(2)+"'",.@ignore);

}

i don't know what .@ignore use i just copy that code somewhere in my files.

}

If the code does not work try this.

I think the update statement do not need any variables since it is only updating.

script sql -1,{

OnAgitBreak:

query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore);

if (getarraysize(.@ignore)>0) {

query_sql("update `woe_record` set `id` = `id`+1 where `guild_id` = '"+getcharid(2)+"'");

}

OnAgitEnd :

query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore);

if (getarraysize(.@ignore)>0) {

query_sql("update `woe_record` set `castle_id` = '"+getcastlename(2)+"' where `guild_id` = '"+getcharid(2)+"'");

}

}

Edited by JayPeeMateo
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

then if .@ignore is no need then i can make it like this one?

if (query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'")) {

query_sql("update `woe_record` set `id` = `id`+1 where `guild_id` = '"+getcharid(2)+"'");

}

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

since you are using SELECT , you need a variable to store it....so ... .@ignore is needed in SELECT case

when you using UPDATE , there is not needed to use the .@ignore since nothing is used to save in that variable...

correct me if i was wrong..>.<

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

it still not recording on my sql

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

i guess you are trying to update the point when the WOE End after the Guild has conquered the Castle...

try this

set .@i,getcastledata( "prtg_cas03",1 );
query_sql("UPDATE `woe_record` SET `id` = `id`+1 WHERE `guild_id` ="+.@i+"");

in your previous case...it wont work..because it need a player to be attached in order to get the information of getcharid( )

hope this work for you ~

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

getcharid(2) is use to find a guild name right?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

*getcharid(<type>{,"<character name>"})

This function will return a unique ID number of the invoking character, or, if a 
character name is specified, of that character.

Type is the kind of associated ID number required:

0 - Character ID number.
1 - Party ID number.
2 - Guild ID number.
3 - Account ID number.
4 - Battle ground ID


it use to find those ID....

but it required a Player to attach to it.....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

i need to attach a player also hmm i will search about that.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

here

- attachrid(<account ID>)

- detachrid;

Like this?

script sql -1,{

OnAgitBreak:

attachrid(getcharid(3),strcharinfo(0));

query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore);

if (getarraysize(.@ignore)>0) {

query_sql("update `woe_record` set `id` = `id`+1 where `guild_id` = '"+getcharid(2)+"'");

}

OnAgitEnd :

attachrid(getcharid(3),strcharinfo(0));

query_sql("select `guild_id` from `woe_record` where `guild_id` = '"+getcharid(2)+"'",.@ignore);

if (getarraysize(.@ignore)>0) {

query_sql("update `woe_record` set `castle_id` = '"+getcastlename(2)+"' where `guild_id` = '"+getcharid(2)+"'");

}

}

Edited by JayPeeMateo
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

*getcharid(<type>{,"<character name>"})

This function will return a unique ID number of the invoking character, or, if a
character name is specified, of that character.

Type is the kind of associated ID number required:

0 - Character ID number.
1 - Party ID number.
2 - Guild ID number.
3 - Account ID number.
4 - Battle ground ID


it use to find those ID....

but it required a Player to attach to it.....

^_^ In order to make use of above Command....you must have provide a Players ID to be attached...or the Player it self must "CLICK" on this NPC..

you cant use any getcharid without a players is attachable.....

attachrid(getcharid(3),strcharinfo(0));

even though you try to make use of attachrid...but your getcharid is unable to attach a players to get the info of getcharid(3)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

Aw I didnt notice that XD.

I think he needs to know what castle has been conquered and then query first the castle holders/owners in the guild_caste db and then query them in woe_record db if they exist (update) and not exist(Insert)?

Edited by JayPeeMateo
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

I thought OnAgitBreak: carried char over, from the mob death triggered event...

does it not?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

/meh ....i didnt realize there is a ...OnAgitBreak Event...i just saw OnAgitEnd ... /ok after all...the above answer / solution...is....useless.. ^_^
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  12/03/11
  • Last Seen:  

i see OnAgitBreak: on agit_template.txt so i need to put that in there?

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...