Jump to content
  • 0

use atcommand to nick name have "space"


LearningRO

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

Hi, All how to solved script atcommand when nickname have space ex : "A B C"

Example Script atcommand 

-	script	DonationUpdate	-1,{
OnInit:
start:
initnpctimer;
end;
OnTimer5000:
set $@nb2,query_sql("SELECT COUNT(*) FROM test_donation WHERE status=0",$@count);
if($@count != 0) {
	set $@nb,query_sql("SELECT id, account_id,donate,status FROM test_donation WHERE status='0'",$@id,$@account_id,$@donate,$@status);
	for (.@i = 0; .@i < $@nb; .@i++) {
		if (isloggedin($@account_id[.@i])) { // check if player online
			atcommand "#cash "+rid2name($@account_id[.@i])+" "+$@donate[.@i];
			query_sql("UPDATE test_donation SET status='1' WHERE id='"+$@id[.@i]+"' AND account_id='"+$@account_id[.@i]+"'");
		}
	}
} else
finish:
stopnpctimer;
goto start;
}

this script only work when nickname player doesn't have space

any idea to solved this issue?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

25 minutes ago, LearningRO said:

Hi, All how to solved script atcommand when nickname have space ex : "A B C"

Example Script atcommand 


-	script	DonationUpdate	-1,{
OnInit:
start:
initnpctimer;
end;
OnTimer5000:
set $@nb2,query_sql("SELECT COUNT(*) FROM test_donation WHERE status=0",$@count);
if($@count != 0) {
	set $@nb,query_sql("SELECT id, account_id,donate,status FROM test_donation WHERE status='0'",$@id,$@account_id,$@donate,$@status);
	for (.@i = 0; .@i < $@nb; .@i++) {
		if (isloggedin($@account_id[.@i])) { // check if player online
			atcommand "#cash "+rid2name($@account_id[.@i])+" "+$@donate[.@i];
			query_sql("UPDATE test_donation SET status='1' WHERE id='"+$@id[.@i]+"' AND account_id='"+$@account_id[.@i]+"'");
		}
	}
} else
finish:
stopnpctimer;
goto start;
}

this script only work when nickname player doesn't have space

any idea to solved this issue?

I dunno why you used npc timers and stuff for this, from what i understood. This should update the cashpoint of a player when loggin in.

This is why you dont use `atcommand` script because it is very inefficient. (personally)

-	script	DonationUpdate	-1,{
OnPCLoginEvent:
	.@aid = getcharid(3);
	query_sql("SELECT `id`, `status`, `donate` FROM `test_donation` WHERE `account_id` = "+.@aid, .@id, .@status, .@donation);
	if ( !.@status ) {
		#CASHPOINTS += .@donation;
		query_sql("UPDATE `test_donation` SET `status`='1' WHERE `id`='"+.@id+"' AND `account_id`="+.@aid);
	}
	end;
}

Although that is untested, but it should work as how i understood your script. Make sure you use this on a test server first to avoid messing up your data.

I believe this should greatly reduce memory usage on your server.

Edit : Changed #CASHPOINT to #CASHPOINTS

PS: I suggest just let players relog instead of putting timers to avoid any unnecessary memory consumption.

Edited by Mabuhay
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

47 minutes ago, Mabuhay said:

I dunno why you used npc timers and stuff for this, from what i understood. This should update the cashpoint of a player when loggin in.

This is why you dont use `atcommand` script because it is very inefficient. (personally)


-	script	DonationUpdate	-1,{
OnPCLoginEvent:
	.@aid = getcharid(3);
	query_sql("SELECT `id`, `status`, `donate` FROM `test_donation` WHERE `account_id` = "+.@aid, .@id, .@status, .@donation);
	if ( !.@status ) {
		#CASHPOINTS += .@donation;
		query_sql("UPDATE `test_donation` SET `status`='1' WHERE `id`='"+.@id+"' AND `account_id`="+.@aid);
	}
	end;
}

Although that is untested, but it should work as how i understood your script. Make sure you use this on a test server first to avoid messing up your data.

I believe this should greatly reduce memory usage on your server.

Edit : Changed #CASHPOINT to #CASHPOINTS

PS: I suggest just let players relog instead of putting timers to avoid any unnecessary memory consumption.

thanks ? i never thinking about that way LOL
thanks a lot broo 

Link to comment
Share on other sites

  • -2

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  233
  • Reputation:   50
  • Joined:  12/20/18
  • Last Seen:  

.

 .

Edited by Disabled LOOLP
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...