Jump to content
  • 0

little question about sql


Question

Posted (edited)

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

16 answers to this question

Recommended Posts

Posted (edited)

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
Posted

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)+"'");

}

Posted

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

Posted

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 ~

Posted

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

Posted (edited)

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
Posted

*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)

Posted (edited)

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...