Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Wont update (https://forums.graalonline.com/forums/showthread.php?t=134258123)

Entrok 02-22-2010 11:23 AM

Wont update
 
I am working on a gui sys for a server and got a problem, im using client.ammo, its showing the img correctly and all, but it wont update if i have client.ammo = 1, and change to 10, then i need to update the script for it to change..

So thats what i need help with right now, so it will update, some one?
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  for (
i=1; i<client.ammo; i+=1)
  {
    
showimg(200+i, "mercia_newgui.png", screenwidth - 302 -(i*4), screenheight - 75);
    
changeimgpart(200+i, 220, 137, 5, 10);
    
changeimgvis(200+i, 5);
  }
  
setshape(1, 32, 32*client.ammo);
  
setTimer(.5);
} 


DrakilorP2P 02-22-2010 01:41 PM

You need to redraw it when the ammo count changes, but I can't help you with that since I don't know the context.

However, a brute force solution can look like this:
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
setTimer(.5);
}

function 
onTimeout()
{
  
hideimgs(200, 300);
  
  for (
i=1; i<client.ammo; i+=1)
  {
    
showimg(200+i, "mercia_newgui.png", screenwidth - 302 -(i*4), screenheight - 75);
    
changeimgpart(200+i, 220, 137, 5, 10);
    
changeimgvis(200+i, 5);
  }
  
setshape(1, 32, 32*client.ammo);
  
setTimer(0.05);
} 


cbk1994 02-22-2010 01:56 PM

Quote:

Originally Posted by DrakilorP2P (Post 1557872)
You need to redraw it when the ammo count changes, but I can't help you with that since I don't know the context.

However, a brute force solution can look like this:

Nooo!! I know your intentions are well but it's never a good idea to start scripters off like that, at least without mentioning the correct way (sorry if I come off rude, not my goal at all).

Ideally the gun system or whatever changes that value would send a "trigger" to the GUI system, and update it. This reduces the processor power needed to run the loop 20 times a second hiding and then reshowing all the images.

Also, not sure what this is supposed to do:
PHP Code:

setshape(1, 32, 32*client.ammo); 

setShape() is for level NPCs. You don't need to use it for setting the size of showimgs :)


All times are GMT +2. The time now is 09:37 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.