Cstrike
2010-11-28 17:00:24
Pyroryan generated a great databse for us.
I edited all the stuff otu because the database is pretty big and would make some browsers crap out, but here's an example of the code
EDIT: Fixed, though will stretch the crap out of Simba.
Takes 15 milliseconds (!) to cycle through the entire array. Love computer power nowadays, and this is on my crap laptop too! In addition, method also got a *huge* library with even more stuff. I don't know how to convert it to this form though (for arrays).
Is this worth adding? Very useful IMO, great for when you don't know the ID of something, and in a function you can just call
EDIT: Condensed function.
I edited all the stuff otu because the database is pretty big and would make some browsers crap out, but here's an example of the code
EDIT: Fixed, though will stretch the crap out of Simba.
{*******************************************************************************
function R_ReturnItem (NameOrID : Variant) : Variant;
By: pyroryan [database, aka: hard work], Cstrke [code, aka easy work]
Description: Input item name/ID to get back ID/item name.
*******************************************************************************}
function R_ReturnItem (NameOrID : Variant) : Variant;
var
ItemIDArray : TIntegerArray;
ItemNameArray : TStringArray;
i : Integer;
begin
ItemIDArray := [6, 8, ]; // shrunk
ItemNameArray := [ 'Cannon base', 'Cannon stand', ]; // shrunk
case VarType(NameOrID) of
varInteger: begin
Result := '';
for i:=0 to high(ItemIDArray) do
if ItemIDArray[i] = NameOrID then
begin
Result := ItemNameArray[i];
Exit;
end;
end;
varString: begin
Result := -1;
for i:=0 to high(ItemNameArray) do
if lowercase(ItemNameArray[i]) = lowercase(NameOrID) then
begin
Result := ItemIDArray[i];
Exit;
end;
end;
else
writeln ('[R_ReturnItem] Warning: Unsupported data type (you must enter an integer or string)');
end;
end;Takes 15 milliseconds (!) to cycle through the entire array. Love computer power nowadays, and this is on my crap laptop too! In addition, method also got a *huge* library with even more stuff. I don't know how to convert it to this form though (for arrays).
Is this worth adding? Very useful IMO, great for when you don't know the ID of something, and in a function you can just call
DepositAllBut (R_ReturnItem('Harpoon'));EDIT: Condensed function.