Blockland Forums > Modification Help
Question(s)
Iban:
The tool index is .tool[0] to .tool[4] on a standard player.
Placid:
--- Quote from: Iban on March 23, 2011, 12:36:50 AM ---The tool index is .tool[0] to .tool[4] on a standard player.
--- End quote ---
alright
--- Code: --- for(%i=0;%i<%c.player.getdatablock().maxtools;%i++) {
%tool=%player.tool[%i];
echo("wat1");
if(!isObject(%player.tool[%i])) {
echo("wat" SPC %i);
%player.tool[%i]=$GunMod::Image[%g];
%player.weaponCount++;
messageClient(%c,'',"\c3" @ $GunMod::Name[%g] SPC "has been bought!");
%c.score = %c.score-$GunMod::Price[%g];
break;
}
--- End code ---
got any ideas why this might be returning true
yes, i've tried < 1
Iban:
I herped a derp. You were missing a messageClient with a specific type called 'MsgItemPickup'
Type in /test, recieve gun.
--- Code: ---// Your formatting is dog richard so let me show you how to make your stuff readable.
// You might be able to solve your own problems if you make it a bit cleaner.
function serverCmdTest(%client)
{
echo("INITIATING TEST.");
%obj = %client.player;
if(!isObject(%obj))
return false;
%maxTools = %obj.getDatablock().maxTools;
echo(" +- 1. Starting Loop");
for(%i = 0; %i < %maxTools; %i++)
{
echo(" +- 2. Loop #" @ %i);
%tool = %obj.tool[%i];
if(!isObject(%tool)
{
echo(" +- +- Unoccupied! Giving a gun.");
%player.tool[%i] = GunItem.getID();
%player.weaponCount++;
messageClient(%client, '', "\c3Gun\c6 purchased!");
%client.score = %c.score -= 5;
// This is the part you were missing. It informs the UI we have a nwe item.
messageClient(%client, 'MsgItemPickup', '', %i, GunItem.getID());
return true;
}
else
{
echo(" +- +- Occupied!");
}
}
echo(" +- 3. FAIL! All slots (" @ %maxTools @ ") occupied!");
return false;
}
--- End code ---
Placid:
--- Quote from: Iban on March 23, 2011, 12:59:36 AM ---I herped a derp. You were missing a messageClient with a specific type called 'MsgItemPickup'
Type in /test, recieve gun.
--- End quote ---
Thanks a lot. There's only one problem now; it gives me the gun image, shows that I have it in slot 4, but it doesn't let me use it. If I scroll down from printer, it shows that I have a printer. If I press q while in slot 4, it doesn't show any item.
lilboarder32:
--- Quote from: Placid on March 23, 2011, 09:05:07 AM ---Thanks a lot. There's only one problem now; it gives me the gun image, shows that I have it in slot 4, but it doesn't let me use it. If I scroll down from printer, it shows that I have a printer. If I press q while in slot 4, it doesn't show any item.
--- End quote ---
Try changing GunItem.getID() to GunImage.getID() in both places.