Author Topic: Code completely blows up blockland.  (Read 921 times)

Code: [Select]
function servercmdSell(%this, %name, %item, %amount){
if(!isObject(%this.player)){return;}
%i = 0;
while(%i<=4){
if(firstWord(%this.player.tool[%i].uiName) $= %item){
for(%i=0;%i<ClientGroup.getCount();%i++){
%cl = ClientGroup.getObject(%i);
if(strstr(strlwr(%cl.name),strlwr(%name))!=-1){
%Customer = %cl;
messageclient(%Customer,"\c0" @ %this.name @ " \c6wants to sell you there \c0" @ %item @ " \c6for \c0" @ %amount @ "\c6.");
}
%i++;
}
}
}
}

Yeah it makes blockland stops responding and i dunno why. Help.

You've got yourself an infinite loop.

Try this (I also fixed some grammar and stuff) :
Code: [Select]
function servercmdSell(%this, %name, %item, %amount){
if(!isObject(%this.player))
return;
%tool = 0;
while(%tool <= 4){
if(firstWord(%this.player.tool[%tool].uiName) $= %item){
for(%i=0;%i<ClientGroup.getCount();%i++){
%cl = ClientGroup.getObject(%i);
if(strstr(strlwr(%cl.name),strlwr(%name)) != -1){
%Customer = %cl;
messageclient(%Customer,"", "\c0" @ %this.name @ " \c6wants to sell you their \c0" @ %item @ " \c6 for \c0" @ %amount @ "\c6.");
}
}
}
%tool++;
}
}
« Last Edit: August 30, 2007, 03:12:19 PM by Randy »

Oh yeah, 2 %i's lmao.

Works thanks.
« Last Edit: August 30, 2007, 03:21:18 PM by MrPickel »