Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-22-2010, 11:23 AM
Entrok Entrok is offline
Registered User
Join Date: Sep 2009
Location: Sweden
Posts: 51
Entrok is on a distinguished road
Send a message via MSN to Entrok
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=1i<client.ammoi+=1)
  {
    
showimg(200+i"mercia_newgui.png"screenwidth 302 -(i*4), screenheight 75);
    
changeimgpart(200+i220137510);
    
changeimgvis(200+i5);
  }
  
setshape(13232*client.ammo);
  
setTimer(.5);

Reply With Quote
  #2  
Old 02-22-2010, 01:41 PM
DrakilorP2P DrakilorP2P is offline
Registered User
DrakilorP2P's Avatar
Join Date: Apr 2006
Posts: 755
DrakilorP2P is just really niceDrakilorP2P is just really nice
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(200300);
  
  for (
i=1i<client.ammoi+=1)
  {
    
showimg(200+i"mercia_newgui.png"screenwidth 302 -(i*4), screenheight 75);
    
changeimgpart(200+i220137510);
    
changeimgvis(200+i5);
  }
  
setshape(13232*client.ammo);
  
setTimer(0.05);

Reply With Quote
  #3  
Old 02-22-2010, 01:56 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DrakilorP2P View Post
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(13232*client.ammo); 
setShape() is for level NPCs. You don't need to use it for setting the size of showimgs
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:45 PM.


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