Jump to content
  • 0
nakano15

Addrid is trolling me

Question

Hey guys, I am back and with a new problem I've been having while scripting npcs on Ragnarok Online.

This time, is with addrid.

 

I am trying to make an script where events may randomly happen in a map and the player can gain something good depending on

how much contribution gave to the event achievement.

The problem is on the part of getting the list of players in the map, it basically does nothing.

When the script is invoked by a player, it works fine, but when the npc invokes the script, it basically does nothing.

                        deletearray(.players[0], 128);
			if(addrid(1, 0) == 1)
			{
				set(.players[getarraysize(.players)], getnpcid(0));
				[email protected] = getarraysize(.players);
				if([email protected] > 0)
				{
					for([email protected] = 0; [email protected] < [email protected]; [email protected]++)
					{
						[email protected]$ = rid2name(.players[[email protected]]);
						detachrid;
						attachrid([email protected]$);
						-- Rest of the script --
					}
					detachrid;
				}
			}

How can I fix this issue? This issue is bothering me have 3 days.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

 
*attachrid(<account ID>)
*detachrid;
 
These commands allow the manipulation of the script's currently attached player.
While 'attachrid' allows attaching of a different player by using its account id
for the parameter RID, 'detachrid' makes the following commands run as if the
script was never invoked by a player. 
 
The command returns 0 if the player cannot be attached (if the account is offline
or does not exist), and 1 upon success.

 

Maybe because you are using the wrong argument?

And, addrid is somewhat confusing for me, in your place I would do a query_sql where char `last_map` = x, using SQL function RANDOM to randomize the result.

Link to comment
Share on other sites

 

 
*attachrid(<account ID>)
*detachrid;
 
These commands allow the manipulation of the script's currently attached player.
While 'attachrid' allows attaching of a different player by using its account id
for the parameter RID, 'detachrid' makes the following commands run as if the
script was never invoked by a player. 
 
The command returns 0 if the player cannot be attached (if the account is offline
or does not exist), and 1 upon success.

 

Maybe because you are using the wrong argument?

And, addrid is somewhat confusing for me, in your place I would do a query_sql where char `last_map` = x, using SQL function RANDOM to randomize the result.

 

Eh, but I does not know how to use sql.

And addrid is surelly confusing.

Link to comment
Share on other sites

Well... After getting angry at Addrid, I tried to do what you suggested, use SQL command by rummaging and googling codes.

It worked, now my script works as it must.

I even made a code file with functions using them so I does not need to rewrite them all the time, maybe later I'll release the file on this forum.

 

Either way, thanks for the help.

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

Important Information

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