Jump to content
  • 0

use atcommand to nick name have "space"


Question

Posted

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?

3 answers to this question

Recommended Posts

  • 0
Posted (edited)
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
  • 0
Posted
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 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...