Jump to content
  • 0

OnPCKillEvent


Feefty

Question


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

what is the best way to use this?

because sometimes it stop working.

i also added sleep2 500; before the actual script run.

buildin_rid2name: invalid RID

Link to comment
Share on other sites

19 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   219
  • Joined:  11/22/11
  • Last Seen:  

maybe you should tell us your ''sometimes'' or we can't help you easily.

Edited by goddameit
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

rid2name(killerrid);

rid2name(killedrid);

As for the actual label... I can't remember if either killerrid or killedrid is attached to the script right away. But that would only help determine if your use of sleep2 was correct. As for your script not working, can't help you there if you don't show us the script.. After all, we're not mind readers.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

I can't remember if either killerrid or killedrid is attached to the script right away. But that would only help determine if your use of sleep2 was correct. As for your script not working, can't help you there if you don't show us the script.. After all, we're not mind readers.

killedrid --> variable set upon killing someone (when "OnPCKillEvent" triggers).

killerrid --> variable set upon dying (when "OnPCDieEvent" triggers).

Edited by Ryokem
Link to comment
Share on other sites


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

OnPCDieEvent also stopped working.

its working fine when its not crowded in the pvp room and sometimes its not working for some players and sometimes it works. its kinda messy.

here's my script

OnPCDieEvent:
sleep2 100;
getmapxy(@map$,@x,@y,0);

for (set .@j,0; .@j<getarraysize(.RiftMaps$); set .@j,.@j+1)
{

 if (@map$ == .RiftMaps$[.@j] && getcharid(2) != getcharid(2, rid2name(killerrid)))
 {
  if (BaseLevel >= 99)
  {
if (@map$ == "guild_vs1")
{
 query_sql("UPDATE `char` SET `deaths` = deaths + 1 WHERE `char_id` = "+getcharid(0));
}
query_sql("SELECT `riftpoints` FROM `char` WHERE `char_id` = "+getcharid(0), @riftpoints);
// get killed rank
set @killedRank, getRank_(@riftpoints);

if (compare(@map$, "g_cas"))
{
 set @lost, .RiftPointsLost[@killedRank]*2;
}
else
{
 set @lost, .RiftPointsLost[@killedRank];
}

if (@riftpoints >= @lost)
{
 set @minus, @riftpoints-@lost;
}
else
{
 set @minus, 0;
}
// update rift points
query_sql("UPDATE `char` SET `riftpoints` = "+@minus+", `riftpoints_last_timestamp` = NOW() WHERE `char_id` = "+getcharid(0));
query_sql("SELECT `riftpoints` FROM `char` WHERE `char_id` = "+getcharid(0), @newRiftPoints);

  }
  // announce the killing
  announce strcharinfo(0)+" "+.RiftRank$[getRank(getcharid(0))]+" was killed by "+rid2name(killerrid)+"'s attack.",bc_area;
  dispbottom("You have died.");

  if (BaseLevel >= 99)
  {
dispbottom("Total Rift Points: "+ Cm(@newRiftPoints));
if (@map$ == "guild_vs1")
{
 dispbottom("Kills: "+getRecord("kills", getcharid(0))+"		  Deaths: "+getRecord("deaths", getcharid(0)));
}
if (getRank_(@riftpoints) > getRank_(@newRiftPoints))
{
 dispbottom("You have been demoted to "+ .RiftRank$[getRank_(@newRiftPoints)]);
}
  }
 }
}
end;
OnPCKillEvent:
sleep2 500;
getmapxy(@map$,@x,@y,0);

for (set .@j,0; .@j<getarraysize(.RiftMaps$); set .@j,.@j+1)
{
 if (@map$ == .RiftMaps$[.@j] && getcharid(2) != getcharid(2, rid2name(killedrid)))
 {
  if (@map$ == "guild_vs1")
  {
query_sql("UPDATE `char` SET `kills` = kills + 1 WHERE `char_id` = "+getcharid(0));
  }
  // if player below level 99
  if (BaseLevel < 99)
  {
dispbottom("You must be level 99 or higher to start gaining Rift Points.");
break;
  }
  query_sql("SELECT `riftpoints` FROM `char` WHERE `char_id` = "+getcharid(0, rid2name(killedrid)), @riftpoints);
  // get my current rift points
  query_sql("SELECT `riftpoints` FROM `char` WHERE `char_id` = "+getcharid(0), @currentRiftPoints);
  // get killed rank
  set @killedRank, getRank_(@riftpoints);
  set @gain, .RiftPointsGain[@killedRank];
  if (getgroupid() == 1)
  {
set @gain, (@gain+((@gain*30)/100));
  }
  if (KillPlayer$ == rid2name(killedrid))
  {
set @gain, (@gain-((@gain*70)/100));
  }
  if (compare(@map$, "g_cas"))
  {
set @gain, @gain*2;
  }
  set KillPlayer$, rid2name(killedrid);
  // update rift points
  query_sql("UPDATE `char` SET `riftpoints` = riftpoints + "+@gain+", `riftpoints_last_timestamp` = NOW() WHERE `char_id` = "+getcharid(0));
  // get my new rift points
  query_sql("SELECT `riftpoints` FROM `char` WHERE `char_id` = "+getcharid(0), @newRiftPoints);
  // display messages
  dispbottom("You have gained "+Cm(@gain)+" Rift Points.");
  dispbottom("You have defeated "+rid2name(killedrid)+" "+.RiftRank$[getRank(getcharid(0, rid2name(killedrid)))]+".");
  dispbottom("Total Rift Points: "+ Cm(@newRiftPoints));
  if (@map$ == "guild_vs1")
  {
dispbottom("Kills: "+getRecord("kills", getcharid(0))+"		  Deaths: "+getRecord("deaths", getcharid(0)));
  }
  if (getRank_(@currentRiftPoints) < getRank_(@newRiftPoints))
  {
dispbottom("You have been promoted to "+ .RiftRank$[getRank_(@newRiftPoints)]);
if (getRank_(@newRiftPoints) >= 9)
{
 announce strcharinfo(0)+" has been promoted to "+.RiftRank$[getRank_(@newRiftPoints)], b_all;
}
  }
  sleep2 60000;
  set KillPlayer$, "";
  break;

 }
}
end;

Edited by Arcenciel
Codeboxed
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

My only guess is that perhaps the OnPCKillEvent & OnPCDieEvent work the same as the variables in getpartymember. In other words, the label runs each instance one by one. If this is the case, then your sleep, command is basically telling the script instance behind it to do its thing. Thus screwing up information and whatnot. But this is only just speculation, but for debugging sake, remove your sleep2 commands and see if you still have a problem.

Link to comment
Share on other sites


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

My only guess is that perhaps the OnPCKillEvent & OnPCDieEvent work the same as the variables in getpartymember. In other words, the label runs each instance one by one. If this is the case, then your sleep, command is basically telling the script instance behind it to do its thing. Thus screwing up information and whatnot. But this is only just speculation, but for debugging sake, remove your sleep2 commands and see if you still have a problem.

i did have the problem before the sleep2 that's why i did add them there and it still didn't work.

i might just rewrite it because this is my first script.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Well, what is this, ' getRank_() ' command i keep seeing you use? I'm fairly certain that's not part of rA's svn, so is it a custom command or is that supposed to be a variable array. In which case your syntax is wrong, and it should look like this: ' getRank_[ ] ' but that's assuming it is indeed a variable array, and not a custom command.

Link to comment
Share on other sites


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

Well, what is this, ' getRank_() ' command i keep seeing you use? I'm fairly certain that's not part of rA's svn, so is it a custom command or is that supposed to be a variable array. In which case your syntax is wrong, and it should look like this: ' getRank_[ ] ' but that's assuming it is indeed a variable array, and not a custom command.

it's a custom function.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Okay then, let's assume the function is working properly. That being said, your variable .RaiftMap$[ ] and .RiftRank[ ], those ARE apart of the same NPC right? Becuase .variables are npc specific unless you use the command ' getvariableofnpc '. And if that's not the issue here, do you have any errors on your map-serv? But, all in all, i can't do a 100% check of this script since i'm using my phone, and well, i don't really have an RO emulator on here lol.

Link to comment
Share on other sites


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

Okay then, let's assume the function is working properly. That being said, your variable .RaiftMap$[ ] and .RiftRank[ ], those ARE apart of the same NPC right? Becuase .variables are npc specific unless you use the command ' getvariableofnpc '. And if that's not the issue here, do you have any errors on your map-serv? But, all in all, i can't do a 100% check of this script since i'm using my phone, and well, i don't really have an RO emulator on here lol.

when i run the server there's no errors.

it only happens when the random killing and dying starts

Edited by Feefty
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

Well, GMOcean is right, you should remove the sleep regardless. If the killer kills multiple people within that .5 s limit, then that already messes things up. If players log out immediately after dying too, before the sleep finishes, it'd mess up also.

In other words, it'll cause you more grief to debug with those in there.

Try having a debugmes(killerrid); and debugmes(killedrid); in PCDieEvent and PCKillEvent respectively, right as the event starts (where sleep2 is). You'll get some string/integer conversion warnings, you can just ignore them.

Your console would show something like:

[Debug] 12345678

[Debug] 12323123

Whenever someone died. And you should be able to monitor what's going on with the RID that way. It might also help to comment your script so you can easily understand your logic if you come back to read it later, might also help you find the issue.

Link to comment
Share on other sites


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

Well, GMOcean is right, you should remove the sleep regardless. If the killer kills multiple people within that .5 s limit, then that already messes things up. If players log out immediately after dying too, before the sleep finishes, it'd mess up also.

In other words, it'll cause you more grief to debug with those in there.

Try having a debugmes(killerrid); and debugmes(killedrid); in PCDieEvent and PCKillEvent respectively, right as the event starts (where sleep2 is). You'll get some string/integer conversion warnings, you can just ignore them.

Your console would show something like:

[Debug] 12345678

[Debug] 12323123

Whenever someone died. And you should be able to monitor what's going on with the RID that way. It might also help to comment your script so you can easily understand your logic if you come back to read it later, might also help you find the issue.

thanks, ill try that

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

buildin_rid2name: invalid RID

comes from script.c

BUILDIN_FUNC(rid2name)
{
   struct block_list *bl = NULL;
   int rid = script_getnum(st,2);
   if((bl = map_id2bl(rid)))
   {
.........
   } else {
       ShowError("buildin_rid2name: invalid RID\n");
       script_pushconststr(st,"(null)");
   }
   return 0;
}]

how to reproduce

-    script    lfhdsfkjs    -1,{
OnPCKillEvent:
   sleep2 500;
   announce strcharinfo(0) +" killed "+ rid2name(killedrid), 0;
   end;
}

get dual client and summon 1 poring

cast lord of vermillion kill both of them ... player and poring at once

and you get that error

if somehow the poring dies a bit later than killing a player

a player was set killedrid into account_id, but killing a mob is set killedrid into mob_id, thus you get this bug

so means you have to remove your sleep2 ...

but seriously ... I'm more interested to know how can your server can get event_queue_full ...

unless you are not using rathena ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

but seriously ... I'm more interested to know how can your server can get event_queue_full ...

unless you are not using rathena ?

That's why after each OnPCKillEvent label, there should be immediately a condition to end the script if not killing the right object.

Or rather... abusing of infinite loops or sql queries haha! xD

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Well, all in all, there is no need for OnPCDieEvent, since in an OnPCKillEvent, both killerrid & killedrid are both character IDs (That is before you activate a sleep command, and let another instance run thus changing the id). So leave it as it may, you can simply just use attachrid(killerrid) & attachrid(killedrid) to do each labels task respectively.

Edit: Btw, are the killerrid & killedrid labels still backwards as ever?

e.g: killedrid = killer | killerrid = killed

Atleast i know in eAthena that was the case, not sure if it still is here. In which case I say, change around lol, because if it is the way it was in the past it's so confusing @.@;

Edited by GmOcean
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  52
  • Reputation:   6
  • Joined:  01/06/12
  • Last Seen:  

but seriously ... I'm more interested to know how can your server can get event_queue_full ...

unless you are not using rathena ?

I was always under the assumption that calling several different event queues in different scripts lead to the queue being full. For example, if you have several scripts that trigger when a player dies, then each event, even though they're all PCDieEvents, get added to the queue separately. Did rAthena change that recently?

Edit: Btw, are the killerrid & killedrid labels still backwards as ever?

e.g: killedrid = killer | killerrid = killed

Atleast i know in eAthena that was the case, not sure if it still is here. In which case I say, change around lol, because if it is the way it was in the past it's so confusing @.@;

killerrid = Person who killed the player, killedrid = Person who the player just killed, last I made a script that used them. Relatively recently.

Yeah, it would be more efficient to trigger only a single event and attachrid to swap between the two. You could also avoid the issue of killing multiple people at once and only being credited for a single kill while using sleep2 if you used OnPCDieEvent.

Edited by Variant
Link to comment
Share on other sites


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

Well, all in all, there is no need for OnPCDieEvent, since in an OnPCKillEvent, both killerrid & killedrid are both character IDs (That is before you activate a sleep command, and let another instance run thus changing the id). So leave it as it may, you can simply just use attachrid(killerrid) & attachrid(killedrid) to do each labels task respectively.

Edit: Btw, are the killerrid & killedrid labels still backwards as ever?

e.g: killedrid = killer | killerrid = killed

Atleast i know in eAthena that was the case, not sure if it still is here. In which case I say, change around lol, because if it is the way it was in the past it's so confusing @.@;

i thought attachrid can only attach the account id?

*attachrid(<account ID>)

or it does attach the char id of the current online char in that account id?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

It attaches the accountID, however the player currently logged in is the one affected. Besides, killerrid & killedrid = acct_ids

Link to comment
Share on other sites


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

It attaches the accountID, however the player currently logged in is the one affected. Besides, killerrid & killedrid = acct_ids

i didn't know that.

Thanks!

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