Jump to content
  • 0
capWinters

Error buildin_getcharid

Question

Good evening ladies and gentlemen!

I'm having problems with a script, and I tried to solve it anyway, seeing that my experience in scripts is very amateur, I come through this to ask you for help. please, of course.

 

This script has to give 100 points only to those who destroy the chest.
And 50 points for the rest of the guild.

For those who destroyed the chest, he gives points without problems, but for the rest of the guild he is not giving it, and I am receiving this error.

 

Sem-t-tulo.png

Script:

Spoiler

OnTimer900000:
announce "[Wot] Os baús apareceram",8;
monster "prt_are_in",178,140,"Bau do Tesouro",1324,1,"War of Treasure::OnThisMobDeath";
stopnpctimer;

OnThisMobDeath:
set @GID,getcharid(0);
set .@ACC,getcharid(3);
query_sql "UPDATE `login` SET `pontoswot` = `pontoswot` +100 WHERE `account_id`="+.@ACC+"";
announce "[Guerra do Tesouro] O jogador ["+strcharinfo(0)+"] do clã ["+getguildname(@GID)+"] acaba de destruir um dos baús!",8;
atcommand "@cash 100";
set .@GUILD,getcharid(2);
query_sql "UPDATE `guild` SET `baus` = `baus` +1 WHERE `guild_id`="+.@GUILD+"";
query_sql "UPDATE `guild` SET `pontosgwot` = `pontosgwot` +50 WHERE `guild_id`="+.@GUILD+"";
end;
}

 

Table:

Spoiler

ALTER TABLE `login` ADD `baus` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `login` ADD `pontoswot` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `guild` ADD `baus` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `guild` ADD `pontosgwot` INT( 11 ) NOT NULL DEFAULT '0';

 

thank you all.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Very bad idea to run sql queries from map server. It will add huge lag to your server.

Probably better save your values into player permanent variables.

 

Your error mean no attached player on mob kill. This probably mean mob was killed not by player.

 

Share this post


Link to post
Share on other sites
  • 0

the login and guild tables should not be used to store variables, it is better to use variables directly, but if you must then you want a query that spans multiple tables, something like

-- give 100 "pontosgwot" to the player that killed it
UPDATE `login` SET `pontosgwot`=`pontosgwot`+100 WHERE `account_id`={{GID}};

-- give 50 "pontosgwot" and 1 "baus" to everyone else in the guild
UPDATE `login` SET `login`.`pontosgwot`=`login.pontosgwot`+50 WHERE `login`.`account_id`=`char.account_id` AND `char`.`guild_id`={{GUILD}} AND `char`.`char_id`<>{{GID}};
UPDATE `login` SET `login`.`baus`=`login.baus`+1 WHERE `login`.`account_id`=`char.account_id` AND `char`.`guild_id`={{GUILD}} AND `char`.`char_id`<>{{GID}};

Replace {{GID}} with the account id and {{GUILD}} with the guild id

 

This is very slow though so don't do this unless you really need to

Share this post


Link to post
Share on other sites
  • 0

@meko, @4144

Thanks for the answer, gentlemen, I was really unaware of the server delay due to these tables, as I am not the author and the script is also very old.

What is the best way to give 100 points to those who destroyed the crowd and 50 points to those who survived the event? kindly.

 

#Edit ...
It is very complex for me.
Changing your mind,
is it possible instead of adding points, add item? for example:
Whoever destroys the mob will win 100 PoringCoin (7539)
And the rest of the clan will win 50?

how do i do that please?

Edited by capWinters
I changed my mind

Share this post


Link to post
Share on other sites
  • 0

if you want to give an item to every guild member on the current map you can use getunits(), something like

.@guild = getcharid(CHAR_ID_GUILD);
.@map$ = getmapinfo(MAPINFO_NAME);

// check to make sure we're not iterating for nothing
if (.@guild && getmapguildusers(.@map$, .@guild) > 1) {
  // get every player on the current map
  .@count = getunits(BL_PC, .@units, false, .@map$);
  // iterate over all those players
  for (.@i = 0; .@i < .@count; ++.@i) {
    // check if they are in the same guild
    if (.@units[.@i] != playerattached() && getcharid(CHAR_ID_GUILD, strcharinfo(PC_NAME, "", .@units[.@i])) == .@guild) {
      getitem({{item}}, {{amount}}, .@units[.@i]);
    }
  }
}

To give to offline guild members you could use the RoDEX system

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

  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.

Loading...

×
×
  • Create New...

Important Information

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