=FAS=Shigawire Posted August 23, 2008 Share Posted August 23, 2008 Hey Guys, I am already working on my lil GUI.. But the weapon part decreases my fps by 15 Frames I chose the easiest and basicst method i know, and idk what to do now. I have this part of the script: ... function updateWeaponSwitch () if ( WeaponStat ) then guiGridListClear ( WeaponStat ) local row1 = guiGridListAddRow ( WeaponStat ) local row2 = guiGridListAddRow ( WeaponStat ) local weaponType = getPlayerWeapon ( getLocalPlayer() ) guiGridListSetItemText ( WeaponStat, row2, column2, " " ..getWeaponNameFromID (weaponType).."", false, false ) black = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.65, "weap/black.bmp", true, WeaponStat ) if ( weaponType == 30 ) then guiStaticImageLoadImage ( black, "weap/akicon.bmp" ) elseif ( weaponType == 0 ) then guiStaticImageLoadImage ( black, "weap/BRASSKNUCKLEicon.bmp" ) elseif ( weaponType == 1 ) then guiStaticImageLoadImage ( black, "weap/BRASSKNUCKLEicon.bmp" ) elseif ( weaponType == 3 ) then guiStaticImageLoadImage ( black, "weap/nitestickicon.bmp" ) elseif ( weaponType == 4 ) then guiStaticImageLoadImage ( black, "weap/knifecuricon.bmp" ) elseif ( weaponType == 22 ) then guiStaticImageLoadImage ( black, "weap/colt45icon.bmp" ) elseif ( weaponType == 23 ) then guiStaticImageLoadImage ( black, "weap/silencedicon.bmp" ) elseif ( weaponType == 24 ) then guiStaticImageLoadImage ( black, "weap/desert_eagleicon.bmp" ) elseif ( weaponType == 25 ) then guiStaticImageLoadImage ( black, "weap/chromegunicon.bmp" ) elseif ( weaponType == 26 ) then guiStaticImageLoadImage ( black, "weap/sawnofficon.bmp" ) elseif ( weaponType == 27 ) then guiStaticImageLoadImage ( black, "weap/shotgspaicon.bmp" ) elseif ( weaponType == 28 ) then guiStaticImageLoadImage ( black, "weap/micro_uziicon.bmp" ) elseif ( weaponType == 29 ) then guiStaticImageLoadImage ( black, "weap/mp5icon.bmp" ) elseif ( weaponType == 32 ) then guiStaticImageLoadImage ( black, "weap/tec9icon.bmp" ) elseif ( weaponType == 30 ) then guiStaticImageLoadImage ( black, "weap/akicon.bmp" ) elseif ( weaponType == 31 ) then guiStaticImageLoadImage ( black, "weap/m4icon.bmp" ) elseif ( weaponType == 35 ) then guiStaticImageLoadImage ( black, "weap/rocketlaicon.bmp" ) elseif ( weaponType == 16 ) then guiStaticImageLoadImage ( black, "weap/grenadeicon.bmp" ) elseif ( weaponType == 17 ) then guiStaticImageLoadImage ( black, "weap/teargasicon.bmp" ) elseif ( weaponType == 18 ) then guiStaticImageLoadImage ( black, "weap/molotovicon.bmp" ) elseif ( weaponType == 39 ) then guiStaticImageLoadImage ( black, "weap/satchelicon.bmp" ) elseif ( weaponType == 44 ) then guiStaticImageLoadImage ( black, "weap/nvgogglesicon.bmp" ) elseif ( weaponType == 45 ) then guiStaticImageLoadImage ( black, "weap/nvgogglesicon.bmp" ) elseif ( weaponType == 46 ) then guiStaticImageLoadImage ( black, "weap/bombicon.bmp" ) end ... These pictures should be updaten when the player is switching the weapon. I used Events instead of timers (Gamersnerd ), but imho its too much work for the Program to update the pictures. Is there a method to make it non-lagging? or making it less FPS loosing? Thank You Link to comment
Ace_Gambit Posted August 23, 2008 Share Posted August 23, 2008 I would recommend to load all your images in advance. That is when the client script is started for example. Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 I would SERIOUSLY recommend to use events... Some that may help: -onClientPlayerWeaponFire -onClientPlayerWeaponSwitch -onClientPlayerWasted With those events, do this: -onClientPlayerWeaponFire: Let it recheck ammo. Or, just let the ammo number go -1. -onClientPlayerWeaponSwitch: Swap code to check everything. If you can make your images .png, they'll be smaller by the way! -onClientPlayerWasted: Let it go on fist, with no ammo. You might need something else for admin panel or freeroam give weapon function. I'll think what will help. EDIT: Ace's performance suggestion would also speed it up dramatically! Make them invisible and on the same position. Then, make the one that you need visible. Good idea or no? Link to comment
=FAS=Shigawire Posted August 23, 2008 Author Share Posted August 23, 2008 Hi, i am using events I saw this works more efficient the onplayerFire and onPlayerWeaponSwitch Events are already used, working fine very good i dea with pre-loading the images, thanks. Iwill try it, when i was able to understand the Server-setup manual "Log-In via SSH"... idk how Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 Hi,i am using events I saw this works more efficient the onplayerFire and onPlayerWeaponSwitch Events are already used, working fine very good i dea with pre-loading the images, thanks. Iwill try it, when i was able to understand the Server-setup manual "Log-In via SSH"... idk how I would still recommend to convert all your pictures to PNG, GIF or JPEG files. Depending on the amount of colors. Low amount? GIF. Middle? PNG. High amount? JP(E)G. BMP sucks space and bandwidth for as far as I know... =/ And didn't see that it was an event... And login via SSH... Never heard of SSH... Link to comment
=FAS=Shigawire Posted August 23, 2008 Author Share Posted August 23, 2008 hi you are right, i didnt show the event, because i thought it isnt necessary to show all lines of my script SSH means SecureShell, i think, i solved this now I will now try to convert all files to png ( im an iditot, these files only got 2 colour: black and white, but i took the highest resolution ) Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 hi you are right, i didnt show the event, because i thought it isnt necessary to show all lines of my script SSH means SecureShell, i think, i solved this now I will now try to convert all files to png ( im an iditot, these files only got 2 colour: black and white, but i took the highest resolution ) Lol! Just take the 32x32 version and stretch it from here to dunnowhere... Link to comment
=FAS=Shigawire Posted August 23, 2008 Author Share Posted August 23, 2008 rofl, that are 44 pictures... I now converted them into png, from 12 kb to 1,5 each one and now i will make them invisible and visible again when it is needed Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 rofl, that are 44 pictures... I now converted them into png, from 12 kb to 1,5 each one and now i will make them invisible and visible again when it is needed Good, let's see if it'll speed it up a little. Link to comment
=FAS=Shigawire Posted August 23, 2008 Author Share Posted August 23, 2008 Lol, now the FPS is not decreasing, but i got the next problem, obciously, he only overlays the pictures: black = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/black.png", true, WeaponStat ) ak = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/akicon.png", true, WeaponStat ) bat = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/baticon.png", true, WeaponStat ) bomb = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/bombicon.png", true, WeaponStat ) brass = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/BRASSKNUCKLEicon.png", true, WeaponStat ) camera = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/Cameraicon.png", true, WeaponStat ) chnsaw = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/chnsawicon.png", true, WeaponStat ) chromegun = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/chromegunicon.png", true, WeaponStat ) colt = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/colt45icon.png", true, WeaponStat ) cuntgun = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/cuntgunicon.png", true, WeaponStat ) deagle = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/desert_eagleicon.png", true, WeaponStat ) flame = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/flameicon.png", true, WeaponStat ) golf = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/golfclubicon.png", true, WeaponStat ) grenade = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/grenadeicon.png", true, WeaponStat ) para = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/gun_paraicon.png", true, WeaponStat ) hsrl = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/heatseekingicon.png", true, WeaponStat ) irgoggles = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/irgogglesicon.png", true, WeaponStat ) jpack = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/jetpackicon.png", true, WeaponStat ) knife = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/knifecuricon.png", true, WeaponStat ) m4 = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/m4icon.png", true, WeaponStat ) uzi = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/micro_uziicon.png", true, WeaponStat ) minigun = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/minigunicon.png", true, WeaponStat ) molotov = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/molotovicon.png", true, WeaponStat ) mp5 = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/mp5icon.png", true, WeaponStat ) nitestick = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/nitestickicon.png", true, WeaponStat ) rocketla = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/rocketlaicon.png", true, WeaponStat ) satchel = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/satchelicon.png", true, WeaponStat ) sawnoff = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/sawnofficon.png", true, WeaponStat ) shotgspa = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/shotgspaicon.png", true, WeaponStat ) silenced = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/silencedicon.png", true, WeaponStat ) sniper = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/SNIPERicon.png", true, WeaponStat ) teargas = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/teargasicon.png", true, WeaponStat ) tec9 = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/tec9icon.png", true, WeaponStat ) guiSetVisible ( black, false ) guiSetVisible ( bat, false ) guiSetVisible ( bomb, false ) guiSetVisible ( brass, false ) guiSetVisible ( camera, false ) guiSetVisible ( chnsaw, false ) guiSetVisible ( chromegun, false ) guiSetVisible ( colt, false ) guiSetVisible ( cuntgun, false ) guiSetVisible ( deagle, false ) guiSetVisible ( flame, false ) guiSetVisible ( golf, false ) guiSetVisible ( grenade, false ) guiSetVisible ( para, false ) guiSetVisible ( hsrl, false ) guiSetVisible ( irgoggles, false ) guiSetVisible ( jpack, false ) guiSetVisible ( knife, false ) guiSetVisible ( m4, false ) guiSetVisible ( uzi, false ) guiSetVisible ( minigun, false ) guiSetVisible ( molotov, false ) guiSetVisible ( nitestick, false ) guiSetVisible ( rocketla, false ) guiSetVisible ( satchel, false ) guiSetVisible ( sawnoff, false ) guiSetVisible ( shotgspa, false ) guiSetVisible ( silenced, false ) guiSetVisible ( sniper, false ) guiSetVisible ( teargas, false ) guiSetVisible ( tec9, false ) guiSetVisible ( mp5, false ) guiSetVisible ( ak, false ) function updateWeaponSwitch () if ( WeaponStat ) then guiGridListClear ( WeaponStat ) local row1 = guiGridListAddRow ( WeaponStat ) local row2 = guiGridListAddRow ( WeaponStat ) local weaponType = getPlayerWeapon ( getLocalPlayer() ) guiGridListSetItemText ( WeaponStat, row2, column2, " " ..getWeaponNameFromID (weaponType).."", false, false ) guiSetVisible ( ak, false ) if ( weaponType == 30 ) then guiSetVisible ( ak, true ) elseif ( weaponType == 0 ) then guiSetVisible ( brass, true ) elseif ( weaponType == 1 ) then guiSetVisible ( brass, true ) elseif ( weaponType == 2 ) then guiSetVisible ( golf, true ) elseif ( weaponType == 3 ) then guiSetVisible ( nitestick, true ) elseif ( weaponType == 4 ) then guiSetVisible ( knife, true ) elseif ( weaponType == 5 ) then guiSetVisible ( bat, true ) elseif ( weaponType == 9 ) then guiSetVisible ( chnsaw, true ) elseif ( weaponType == 22 ) then guiSetVisible ( colt, true ) elseif ( weaponType == 23 ) then guiSetVisible ( silenced, true ) elseif ( weaponType == 24 ) then guiSetVisible ( deagle, true ) elseif ( weaponType == 25 ) then guiSetVisible ( chromegun, true ) elseif ( weaponType == 26 ) then guiSetVisible ( sawnoff, true ) elseif ( weaponType == 27 ) then guiSetVisible ( shotgspa, true ) elseif ( weaponType == 28 ) then guiSetVisible ( uzi, true ) elseif ( weaponType == 29 ) then guiSetVisible ( mp5, true ) elseif ( weaponType == 32 ) then guiSetVisible ( tec9, true ) end end end addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), updateWeaponSwitch) I didnt enter all Weapon IDs becuase i am 1. very tired and 2. do i want to check, if its working. ATm its not properly: he shows 3 pictures right, the he stops at the current picture and doesnt go on, tomorrow i will make a video of that, if there isnt a solution until then Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 Lol, now the FPS is not decreasing, but i got the next problem, obciously, he only overlays the pictures: black = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/black.png", true, WeaponStat ) ak = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/akicon.png", true, WeaponStat ) bat = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/baticon.png", true, WeaponStat ) bomb = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/bombicon.png", true, WeaponStat ) brass = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/BRASSKNUCKLEicon.png", true, WeaponStat ) camera = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/Cameraicon.png", true, WeaponStat ) chnsaw = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/chnsawicon.png", true, WeaponStat ) chromegun = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/chromegunicon.png", true, WeaponStat ) colt = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/colt45icon.png", true, WeaponStat ) = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/:O.png", true, WeaponStat ) deagle = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/desert_eagleicon.png", true, WeaponStat ) flame = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/flameicon.png", true, WeaponStat ) golf = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/golfclubicon.png", true, WeaponStat ) grenade = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/grenadeicon.png", true, WeaponStat ) para = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/gun_paraicon.png", true, WeaponStat ) hsrl = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/heatseekingicon.png", true, WeaponStat ) irgoggles = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/irgogglesicon.png", true, WeaponStat ) jpack = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/jetpackicon.png", true, WeaponStat ) knife = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/knifecuricon.png", true, WeaponStat ) m4 = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/m4icon.png", true, WeaponStat ) uzi = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/micro_uziicon.png", true, WeaponStat ) minigun = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/minigunicon.png", true, WeaponStat ) molotov = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/molotovicon.png", true, WeaponStat ) mp5 = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/mp5icon.png", true, WeaponStat ) nitestick = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/nitestickicon.png", true, WeaponStat ) rocketla = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/rocketlaicon.png", true, WeaponStat ) satchel = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/satchelicon.png", true, WeaponStat ) sawnoff = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/sawnofficon.png", true, WeaponStat ) shotgspa = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/shotgspaicon.png", true, WeaponStat ) silenced = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/silencedicon.png", true, WeaponStat ) sniper = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/SNIPERicon.png", true, WeaponStat ) teargas = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/teargasicon.png", true, WeaponStat ) tec9 = guiCreateStaticImage( 0.2, 0.3, 0.6, 0.4, "weap/tec9icon.png", true, WeaponStat ) guiSetVisible ( black, false ) guiSetVisible ( bat, false ) guiSetVisible ( bomb, false ) guiSetVisible ( brass, false ) guiSetVisible ( camera, false ) guiSetVisible ( chnsaw, false ) guiSetVisible ( chromegun, false ) guiSetVisible ( colt, false ) guiSetVisible ( , false ) guiSetVisible ( deagle, false ) guiSetVisible ( flame, false ) guiSetVisible ( golf, false ) guiSetVisible ( grenade, false ) guiSetVisible ( para, false ) guiSetVisible ( hsrl, false ) guiSetVisible ( irgoggles, false ) guiSetVisible ( jpack, false ) guiSetVisible ( knife, false ) guiSetVisible ( m4, false ) guiSetVisible ( uzi, false ) guiSetVisible ( minigun, false ) guiSetVisible ( molotov, false ) guiSetVisible ( nitestick, false ) guiSetVisible ( rocketla, false ) guiSetVisible ( satchel, false ) guiSetVisible ( sawnoff, false ) guiSetVisible ( shotgspa, false ) guiSetVisible ( silenced, false ) guiSetVisible ( sniper, false ) guiSetVisible ( teargas, false ) guiSetVisible ( tec9, false ) guiSetVisible ( mp5, false ) guiSetVisible ( ak, false ) function updateWeaponSwitch () if ( WeaponStat ) then guiGridListClear ( WeaponStat ) local row1 = guiGridListAddRow ( WeaponStat ) local row2 = guiGridListAddRow ( WeaponStat ) local weaponType = getPlayerWeapon ( getLocalPlayer() ) guiGridListSetItemText ( WeaponStat, row2, column2, " " ..getWeaponNameFromID (weaponType).."", false, false ) guiSetVisible ( ak, false ) if ( weaponType == 30 ) then guiSetVisible ( ak, true ) elseif ( weaponType == 0 ) then guiSetVisible ( brass, true ) elseif ( weaponType == 1 ) then guiSetVisible ( brass, true ) elseif ( weaponType == 2 ) then guiSetVisible ( golf, true ) elseif ( weaponType == 3 ) then guiSetVisible ( nitestick, true ) elseif ( weaponType == 4 ) then guiSetVisible ( knife, true ) elseif ( weaponType == 5 ) then guiSetVisible ( bat, true ) elseif ( weaponType == 9 ) then guiSetVisible ( chnsaw, true ) elseif ( weaponType == 22 ) then guiSetVisible ( colt, true ) elseif ( weaponType == 23 ) then guiSetVisible ( silenced, true ) elseif ( weaponType == 24 ) then guiSetVisible ( deagle, true ) elseif ( weaponType == 25 ) then guiSetVisible ( chromegun, true ) elseif ( weaponType == 26 ) then guiSetVisible ( sawnoff, true ) elseif ( weaponType == 27 ) then guiSetVisible ( shotgspa, true ) elseif ( weaponType == 28 ) then guiSetVisible ( uzi, true ) elseif ( weaponType == 29 ) then guiSetVisible ( mp5, true ) elseif ( weaponType == 32 ) then guiSetVisible ( tec9, true ) end end end addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), updateWeaponSwitch) I didnt enter all Weapon IDs becuase i am 1. very tired and 2. do i want to check, if its working. ATm its not properly: he shows 3 pictures right, the he stops at the current picture and doesnt go on, tomorrow i will make a video of that, if there isnt a solution until then First: I would like to recommend you to change getRootElement() in the event handler to getLocalPlayer(). Second: Wouldn't a table and a loop be better than so many lines? Third: > Link to comment
=FAS=Shigawire Posted August 23, 2008 Author Share Posted August 23, 2008 1. Ok 2. I never did a loop, and what do you mean with table? I have to look in the wiki how it works 3. Thanks Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 1. Ok 2. I never did a loop, and what do you mean with table? I have to look in the wiki how it works 3. Thanks A loop is that it repeats the same lines over and over again, until you don't need it anymore. Handy in such cases! And tables are really cool! I'll show an example (which I did not test) right here! Both table and loop. weaponsTable = {29, 27, 24} function giveMeWeapons(thePlayer) for k,v in ipairs(weaponstable) do giveWeapon(thePlayer,v,9999) end end addCommandHandler("gimmeweapons",getRootElement(),giveMeWeapons) A simple table, containing the 3 weapons. The for-loop loops through them, and gives each of them to the player. That's actually all it does. Making it a bit more advanced: (but also more likely it doesn't work... ) weaponsTable = { {29,1}, {27,2}, {24,3} } function giveMeWeapons(thePlayer) for k,v in ipairs(weaponsTable) do giveWeapon(thePlayer,weaponsTable[k+1][1],weaponsTable[k+1][2]) end end addCommandHandler("gimmeweapons",getRootElement(),giveMeWeapons) This one is also adjustable in ammo! Yay! Link to comment
=FAS=Shigawire Posted August 23, 2008 Author Share Posted August 23, 2008 Ouch, looks difficult. what is the k and the v representing? and how could i use it in my case? Link to comment
Ace_Gambit Posted August 23, 2008 Share Posted August 23, 2008 Have a look at this: http://lua-users.org/wiki/TutorialDirectory. Link to comment
Gamesnert Posted August 23, 2008 Share Posted August 23, 2008 Ouch, looks difficult.what is the k and the v representing? and how could i use it in my case? k=key v=value k stands for the number of the current piece of table. v stands for what it contains. You can learn about tables here: http://www.lua.org/pil/2.5.html http://www.lua.org/pil/3.6.html A bit difficult, but pay attention and you'll get it. About for, while and repeat loops: while: http://www.lua.org/pil/4.3.2.html repeat:http://www.lua.org/pil/4.3.3.html for:http://www.lua.org/pil/4.3.4.html for:http://www.lua.org/pil/4.3.5.html Might be a whole lot coming to you at the same time, but learning this will give you great new opportunities in scripting! I actually use XML in combination with tables and for+while loops for my account saving. But you decide what you're going to use it for, it's flexible, can reduce filesize and it cleans up your script! Then you don't have those huge amount lines anymore! If you need any help with learning tables/loops, feel free to ask. Link to comment
=FAS=Shigawire Posted August 24, 2008 Author Share Posted August 24, 2008 Ok, thank you all, i will have a look on this. Seems it would need more time than i expected... Edit: rofl, atm its too high for me, i learned LUA through reading and testing the wiki examples .DD gonna see if i can do the same with tables and loops BUt now i understood your weapon script. But im am not sure how to use it in my script. Maybe k = weaponID and v= path of the picture? Edit2: I am an Idiot, i forgot to make the pictures invisible before switching the weapon Now it works, FPS are around 39-43 ( before : 43-45 ) Link to comment
Gamesnert Posted August 24, 2008 Share Posted August 24, 2008 Ok, thank you all, i will have a look on this. Seems it would need more time than i expected...Edit: rofl, atm its too high for me, i learned LUA through reading and testing the wiki examples .DD gonna see if i can do the same with tables and loops BUt now i understood your weapon script. But im am not sure how to use it in my script. Maybe k = weaponID and v= path of the picture? Edit2: I am an Idiot, i forgot to make the pictures invisible before switching the weapon Now it works, FPS are around 39-43 ( before : 43-45 ) Lol, you ARE an idiot! Nah just kidding, just happens to everyone here sometimes. Anyway, k isn't weaponID, v isn't path of the picture. Look: The loop loops through the table. The first variable, k, indicates at which position in the table it is. v indicates what it contains. So if you take a look at the table and script: weaponsTable = { {29,1}, {27,2}, {24,3} } function giveMeWeapons(thePlayer) for k,v in ipairs(weaponsTable) do giveWeapon(thePlayer,weaponsTable[k+1][1],weaponsTable[k+1][2]) end end addCommandHandler("gimmeweapons",getRootElement(),giveMeWeapons) If k=1, v would be {29,1}. If k=2, v would be {27,2} etc. Simple as that. How to use it in your script? I'll take a look: <code that defines all the static images should be here. So ak = guiCreateStaticImage... etc. should be above the table!> staticImages={black, bat, bomb, brass, camera, chnsaw, chromegun, colt, , deagle, flame, golf, grenade, para, hsrl, irgoggles, jpack, knife, m4, uzi, minigun, molotov, nitestick, rocketla, satchel, sawnoff, shotgspa, silenced, sniper, teargas, tec9, mp5, ak} for k,v in ipairs(staticImages) do guiSetVisible(v,false) end Just something like that. You see how easy that is? Now again, it's untested! But it should work if you place it at the correct spot I think. You need to place it at the same spot you placed all of the guiSetVisible's, otherwise it won't know what "black" or whatever means. Now another hint: When the weapon change is activated, you may want to run the for loop again, so every picture is invisible except the one you need. Without needing about 32 lines of code. ^^ (Note: you can skip the table part in that case! Since the table is then already set! ^^) Link to comment
=FAS=Shigawire Posted August 24, 2008 Author Share Posted August 24, 2008 Wow, thank you Now its very easy Link to comment
Gamesnert Posted August 24, 2008 Share Posted August 24, 2008 Hehehe! Told ya! There are many reasons why to use for's, whiles and tables. Especially in combination. Always keep an eye for things you need to repeat over and over again. Link to comment
=FAS=Shigawire Posted August 24, 2008 Author Share Posted August 24, 2008 hmm, sounds pretty nice, but atm the fps problem came back. And i donkt know why. I made the addEventHandler with the Event "OnClientPalyerWeaponSwitch" then i want to add a new column, but each time i switch my weapon, the fps goes down to 30 I disabled the command line addEventHandler, and then the fps still stay at 45 : ...weaponfunction... end addEventHandler ( "onClientPlayerWeaponSwitch", getLocalPlayer(), updateWeaponSwitch) outputChatBox ( "#FF0000Hello #00FF00World", getRootElement(), 255, 255, 255, true ) -- only wanted to test of the fps is going down when this is typed... local AmmoStat = guiCreateGridList ( 0.61675, 0.02, 0.15, 0.12, true, window ) -- also if i enable only this one line, the fps goes down... i wonder why. local columna1 = guiGridListAddColumn( AmmoStat, "Ammunation", 0.85 ) local rowa1 = guiGridListAddRow ( AmmoStat ) local rowa2 = guiGridListAddRow ( AmmoStat ) local rowa3 = guiGridListAddRow ( AmmoStat ) local rowa4 = guiGridListAddRow ( AmmoStat ) local rowa5 = guiGridListAddRow ( AmmoStat ) local rowa6 = guiGridListAddRow ( AmmoStat ) guiGridListSetItemText ( AmmoStat, rowa1, columna1, "Your total Ammo:", false, false ) guiGridListSetItemText ( AmmoStat, rowa2, columna1, " ssssssss", false, false ) ... Seems the Events/commands after the "OnClientPlayerSwitchWeapon" are updated. That is crazy Link to comment
Gamesnert Posted August 24, 2008 Share Posted August 24, 2008 hmm, sounds pretty nice, but atm the fps problem came back. And i donkt know why.I made the addEventHandler with the Event "OnClientPalyerWeaponSwitch" then i want to add a new column, but each time i switch my weapon, the fps goes down to 30 I disabled the command line addEventHandler, and then the fps still stay at 45 : ...weaponfunction... end addEventHandler ( "onClientPlayerWeaponSwitch", getLocalPlayer(), updateWeaponSwitch) outputChatBox ( "#FF0000Hello #00FF00World", getRootElement(), 255, 255, 255, true ) -- only wanted to test of the fps is going down when this is typed... local AmmoStat = guiCreateGridList ( 0.61675, 0.02, 0.15, 0.12, true, window ) -- also if i enable only this one line, the fps goes down... i wonder why. local columna1 = guiGridListAddColumn( AmmoStat, "Ammunation", 0.85 ) local rowa1 = guiGridListAddRow ( AmmoStat ) local rowa2 = guiGridListAddRow ( AmmoStat ) local rowa3 = guiGridListAddRow ( AmmoStat ) local rowa4 = guiGridListAddRow ( AmmoStat ) local rowa5 = guiGridListAddRow ( AmmoStat ) local rowa6 = guiGridListAddRow ( AmmoStat ) guiGridListSetItemText ( AmmoStat, rowa1, columna1, "Your total Ammo:", false, false ) guiGridListSetItemText ( AmmoStat, rowa2, columna1, " ssssssss", false, false ) ... Seems the Events/commands after the "OnClientPlayerSwitchWeapon" are updated. That is crazy Creating GUI stuff always slows the PC down a bit. Try making a good GUI and create it mid-game. Loading time is just crazy sometimes... Again I would suggest making every GUI item at the start of the resource and on join and making them invisible. Making you capable of making them visible when needed without lag. Link to comment
=FAS=Shigawire Posted August 24, 2008 Author Share Posted August 24, 2008 These GUIs are needed all the time maybe i could set the 3rd window into a several script..? Edit: Doenst solve the problem with 2 several scripts and even 2 several resources the FPS go down ... i will have to make it smaller... Link to comment
Gamesnert Posted August 24, 2008 Share Posted August 24, 2008 These GUIs are needed all the time maybe i could set the 3rd window into a several script..? Edit: Doenst solve the problem with 2 several scripts and even 2 several resources the FPS go down ... i will have to make it smaller... Ehm... I was talking about the gridlist... I don't think that one's needed all the time... =/ Link to comment
=FAS=Shigawire Posted August 24, 2008 Author Share Posted August 24, 2008 These GUIs are needed all the time maybe i could set the 3rd window into a several script..? Edit: Doenst solve the problem with 2 several scripts and even 2 several resources the FPS go down ... i will have to make it smaller... Ehm... I was talking about the gridlist... I don't think that one's needed all the time... =/ what do you mean? I was sure the gridlist is needed all the time... but i dont check why the fps decrease when i want to make the 3rd column/gridlist Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now