106
Modification Help / Buying and selling.
« on: August 31, 2007, 07:52:50 AM »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 " @ $currency @ "\c0" @ %amount @ "\c6.");
messageclient(%Customer,"","\c6Please type /buy yes " @ %this.name @ %item @ "if you'd like to buy it.");
%client.saleItem = %item;
%client.saleItemPrice = %amount;
}
}
}
%tool++;
}
}
function serverCmdBuy(%client, %yesNo, %name, %item){
if(%yesNo $= "yes"){
for(%i=0;%i<ClientGroup.getCount();%i++){
%cl = ClientGroup.getObject(%i);
if(strstr(strlwr(%cl.name),strlwr(%name)) != -1){
if(%cl.saleItem $= %item && %client.cash >= %cl.saleItem.price){
for(%tool=0; %tool<5; %tool++){
if(firstWord(%cl.player.tool[%tool].uiName) $= %item){
%client.cash = %client.cash-%cl.saleItemPrice;
%cl.cash = %cl.cash+%cl.saleItemPrice;
%cl.player.tool[%tool] = nametoID(firstWord(%item));
messageClient(%client, 'MsgItemPickup', '', %tool, nametoID(firstWord(%item)));
%cl.player.tool[%tool] = nametoID();
messageClient(%cl, 'MsgItemPickup', '', %tool, nametoID());
%cl.saleItem = " ";
%cl.saleItemPrice = " ";
}
}
}
}
}
}
}
Yeah, it's not working and i dunno why.