Quote:
Originally Posted by Cubical
the script
|
Okay.
I want to replace the old classic inventory with my own one. I changed the key to "Q", but both inventories popped up..lol How can I easily disable the old classic one? Also, is there a way to drag out items and drop them on the ground?
I thought editing this would help..but I failed
PHP Code:
player.chat = "You can't drop this!";
return;
}
Inventory_Window.visible = false;
this.dragging = true;
this.dragWep = ( @ ct ).weapon;
Inventory_DragImg.image = ( @ ct ).weapon.image;
Inventory_DragQuantity.text = 1;
refreshDrag();
Inventory_DragImg.visible = true;
Inventory_DragQuantity.visible = true;
this.startDrag = timevar2;
client.frozen = true;
}
function refreshDrag()
Here's the code:
PHP Code:
function onActionServerSide( cmd, wep, amm, img, acc )
{
}
//echo(wep SPC clientr.item.( @ wep ) SPC player.account);
if ( clientr.item.( @ wep ) >= amm )
{
clientr.item.( @ wep ) -= amm;
if ( clientr.item.( @ wep ) == 0 )
{
removeweapon( wep );
}
temp.npc = putnpc2( dropPosition()[0], dropPosition()[1], "join(\"object_droppeditem\");" );
temp.npc.dropper = acc;
temp.npc.realName = wep;
temp.npc.itemQuantity = amm;
temp.npc.itemImage = img;
clientr.trueMoney = base64encode( clientr.item.Money );
triggerclient( "gui", name, "reopenMenu" );
}
function dropPosition()
{
temp.playerPos = {{0.75, 1}, {0.6, 1.5}};
temp.dropPos = {
player.x + (player.dir in {0, 2}? temp.playerPos[0][0] : temp.playerPos[1][0]) + vecx(player.dir) * 2,
player.y + (player.dir in {0, 2}? temp.playerPos[0][1] : temp.playerPos[1][1]) + vecy(player.dir) * 2
};
return temp.dropPos;
}
//#CLIENTSIDE
function onCreated()
{
setTimer( 0.05 );
}
function onActionClientSide( cmd )
{
if ( cmd == "reopenMenu" )
{
if ( this.menu == 1 )
{
destroyMenu();
showMenu();
}
else
{
destroyMenu();
}
}
}
function onKeyPressed( code, key )
{
if ( key == "w" )
{
this.menu = 1 - this.menu;
if ( this.menu )
{
showMenu();
setTimer( 0.05 );
}
else
{
destroyMenu();
this.scroll = 0;
}
}
}
function onTimeOut()
{
if ( mousewheeldelta > 0 )
{
if ( this.scroll + 35 < this.iWeps.size() )
{
this.scroll += 5;
destroyMenu();
showMenu();
}
}
else if ( mousewheeldelta < 0 )
{
if ( this.scroll > 0 )
{
this.scroll -= 5;
destroyMenu();
showMenu();
}
}
if ( this.dragging )
{
temp.i = Inventory_DragQuantity.text;
if ( timevar2 - this.lastTime >= .1 )
{
if ( keydown( 0 ) )
{
if ( temp.i != clientr.item.( @ this.dragWep.name ) )
{
Inventory_DragQuantity.text = temp.i + 1;
this.lastTime = timevar2;
}
}
if ( keydown( 1 ) )
{
if ( temp.i - 100 > 0 )
{
Inventory_DragQuantity.text = temp.i - 100;
// this.lastTime = timevar2;
}
else
{
Inventory_DragQuantity.text = 1;
//this.lastTime = timevar2;
}
}
if ( keydown( 2 ) )
{
if ( temp.i > 1 )
{
Inventory_DragQuantity.text = temp.i - 1;
this.lastTime = timevar2;
}
}
if ( keydown( 3 ) )
{
if ( temp.i + 100 <= clientr.item.( @ this.dragWep.name ) )
{
Inventory_DragQuantity.text = temp.i + 100;
//this.lastTime = timevar2;
}
else
{
Inventory_DragQuantity.text = clientr.item.( @ this.dragWep.name );
//this.lastTime = timevar2;
}
}
}
if ( ! leftmousebutton )
{
endDragging();
}
else
{
refreshDrag();
}
}
if ( this.menu )
{
setTimer( 0.05 );
}
}
function destroyMenu()
{
Inventory_Window.destroy();
}
function showMenu()
{
iWeps.clear();
for ( temp.a : player.weapons )
{
temp.n = temp.a.name;
if ( ! temp.n.starts( "-" ) )
{
iWeps.add( temp.a );
}
}
this.iWeps = iWeps;
scroll = this.scroll;
new GuiShowImgCtrl( "Inventory_DragImg" )
{
image = "";
x = 0;
y = 0;
visible = false;
width = 32;
height = 32;
}
new GuiShowImgCtrl( "Inventory_Window" )
{
image = "inventory1.png";
width = 380;
height = 380;
x = screenwidth / 3 - ( width / 20 );
y = screenheight / 2 - ( height / 3 );
visible = true;
for ( temp.i = scroll; temp.i < 35 + scroll; temp.i ++ )
{
if ( temp.i < iWeps.size() )
{
temp.a = iWeps[temp.i];
if ( temp.cols == 5 )
{
temp.row ++;
temp.cols = 0;
}
new GuiShowImgCtrl( "Inventory_Item_" @ temp.a.name )
{
image = temp.a.image;
x = 13 + ( 60.5 * temp.cols );//108-x/original|35|
y = 8 + ( 43.5 * temp.row );//9-y/original|35|
//Newer Old-x=27.5
//Newer Old-y=96
width = 32;
height = 32;
hint = temp.a.name;
this.weapon = temp.a;
thiso.catchevent( name, "onMouseDown", "onItemClicked" );
thiso.catchevent( name, "onMouseDragged", "onItemDragged" );
}
temp.cols ++;
}
}
}
onSelect( ( @ "Inventory_Item_" @ player.weapons[selectedweapon].name ) );
}
function onItemClicked( ctr, n, x, y, count )
{
temp.c = ( @ ctr );
temp.w = temp.c.weapon;
if ( count == 2 )
{
onEquip( ctr );
}
else
{
onSelect( ctr );
}
}
function onItemDragged( ctrln, n, x, y )
{
if ( ! this.dragging )
{
startDragging( ctrln );
}
}
function startDragging( ct )
{
if ( ( @ ct ).weapon.name == NULL )
{
player.chat = "You can't drop this!";
return;
}
Inventory_Window.visible = false;
this.dragging = true;
this.dragWep = ( @ ct ).weapon;
Inventory_DragImg.image = ( @ ct ).weapon.image;
Inventory_DragQuantity.text = 1;
refreshDrag();
Inventory_DragImg.visible = true;
Inventory_DragQuantity.visible = true;
this.startDrag = timevar2;
client.frozen = true;
}
function refreshDrag()
{
player.dir = getdir( mousex - player.x, mousey - player.y );
if ( mousex in | player.x - 10, player.x + 10 | && mousey in | player.y - 10, player.y + 10 |)// && ( timevar2 - this.startDrag > .5 ) )
{
setAni( "grab", Inventory_DragImg.image );
}
else
{
setAni( "idle", "" );
}
Inventory_DragImg.x = mousescreenx - 25;
Inventory_DragImg.y = mousescreeny - 25;
Inventory_DragQuantity.x = mousescreenx - 30;
Inventory_DragQuantity.y = mousescreeny - 20;
Inventory_DragImg.showtop();
}
function endDragging()
{
Inventory_Window.visible = true;
if ( this.dragWep.name == "Medkit" )
{
for (a: allplayers)
{
if ( player.x in |a.x - 2, a.x + 2| && player.y in |a.y - 2, a.y + 2| )
{
if ( a.account != player.account )
{
triggerserver( "weapon", name, "revive", a.account );
this.dragging = false;
Inventory_DragImg.image = "";
Inventory_DragImg.visible = true;
Inventory_DragQuantity.text = "";
Inventory_DragQuantity.visible = false;
this.dragWep = "";
client.frozen = false;
}
}
}
}
elseif ( mousex in | player.x - 10, player.x + 10 | && mousey in | player.y - 10, player.y + 10 | && ( timevar2 - this.startDrag > .5 ) )
{
triggerserver( "gui", name, "dropItem", this.dragWep.name, Inventory_DragQuantity.text, this.dragWep.image, player.account );
}
else
{
setAni( "idle", "" );
}
this.dragging = false;
Inventory_DragImg.image = "";
Inventory_DragImg.visible = false;
Inventory_DragQuantity.text = "";
Inventory_DragQuantity.visible = false;
this.dragWep = "";
client.frozen = false;
}
function onSelect( ctrl )
{
temp.n = ( @ ctrl ).weapon.name;
temp.a = temp.n.tokenize( "/" );
if ( temp.a.size() == 2 )
{
Inventory_ItemName.text = "Item:" SPC temp.a[1];
}
else
{
Inventory_ItemName.text = "Item:" SPC temp.a[0];
}
Inventory_ItemQuantity.text = "Quantity:" SPC clientr.item.( @ temp.n );
Inventory_Icon.image = ( @ ctrl ).weapon.image;
}
function onEquip( ctrl3 )
{
temp.w = ( @ ctrl3 ).weapon.name;
for ( temp.i = 0; temp.i < player.weapons.size(); temp.i ++ )
{
temp.a = player.weapons[temp.i];
if ( temp.a.name == temp.w )
{
selectedweapon = temp.i;
}
}
}