Jump to content
  • 0

[RESOLVIDO] O nome do jogador na tabela do ranking pvp some quando o personagem não está online


Tdi123

Question


  • Group:  Members
  • Topic Count:  92
  • Topics Per Day:  0.04
  • Content Count:  192
  • Reputation:   3
  • Joined:  12/12/17
  • Last Seen:  

Exemplo 1 (Personagem Online):

1.png.2af04b521d1f5f61005156a31802d63d.png

Exemplo 2 (Personagem Offline):

2.png.67a0fb46dce4d37e12541eea2d039edb.png

ERROR no Emulador:

3.png.96b0886f6edd0452568d2593c759adbe.png

Tabela SQL: 

Quote

DROP TABLE IF EXISTS `pvp_ladder`;
CREATE TABLE IF NOT EXISTS `pvp_ladder` (
  `char_id` int(11) UNSIGNED NOT NULL,
  `count` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`char_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

SCRIPT: 

Quote

set .rankpoint, 1; //Ranking PvP? (0:Disable)

if(.rankpoint < 0){ set .rankpoint, 0; }

if(.rankpoint){ query_sql("INSERT INTO `pvp_ladder` SET `char_id` = '"+getcharid(0)+"', `count` = '1' ON DUPLICATE KEY UPDATE `count` = `count`+1"); }

//Player Ranking
        mes "^FF7F00[ Arena PvP ]^000000";
        if(!(.@nb = query_sql("SELECT `char_id`, `count` FROM `pvp_ladder` ORDER BY `count` DESC LIMIT 10", .@cid, .@count))) {
        mes "Nenhuma morte foi contabilizada ainda.";
        close;
        }
        mes "Top 10 PvP:";
        for ( .@i = 0; .@i < .@nb; .@i++ )
        mes (.@i+1) +". "+ strcharinfo(0,.@cid[.@i]) +": ^008aff"+ .@count[.@i] +"^000000";
        close;

Agradeço a ajuda desde já!

EDIT 1 SOLUÇÃO:

SQL: 

Quote

ALTER TABLE `char` ADD `pvp_kill` INT(11) UNSIGNED NOT NULL DEFAULT '0'  AFTER `fame`;

SCRIPT: 

Quote

//Player Ranking
mes "^FF7F00[ Arena PvP ]^000000";
mes "TOP 10 PvP:";
query_sql( "SELECT `name`,`pvp_kill` FROM `char` WHERE `pvp_kill` > 0 ORDER BY `pvp_kill` DESC LIMIT 10", .@name$, .@pvp_kill );
.@size = getarraysize( .@name$ );
for ( .@i = 0; .@i < .@size; .@i++ ) {
mes "^ff0000"+(.@i + 1 )+"°^000000 "+.@name$[.@i]+" - ^008aff"+.@pvp_kill[.@i]+" kill(s)^000000";
}
close;

RESET: 

Quote

query_sql("UPDATE `char` SET `pvp_kill` = 0 WHERE `pvp_kill` > 0");

CONTADOR:

Quote

OnPCKillEvent:
if ( getcharid(3) != killedrid ) {
    query_sql( "UPDATE `char` SET `pvp_kill` = `pvp_kill` + 1 WHERE `char_id` = "+getcharid(0)+" LIMIT 1" );
}
end;

BOM PROVEITO!

Edited by Tdi123
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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