Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Old Scripting Engine (GS1) (https://forums.graalonline.com/forums/forumdisplay.php?f=154)
-   -   goggles (https://forums.graalonline.com/forums/showthread.php?t=63513)

excaliber7388 01-17-2006 11:05 PM

goggles
 
1 Attachment(s)
This is an NPC for Infrared goggles, half of the script isn't here (the part for setting the colors, because we have a day/night system that needs to be countered). Anyway, it kinda works, my only problems with it is that it counts some NPCs as players, not just npcs with showcharacter, but also random ones without showcharacter. Also, players can see the glow around themselves, even if they aren't using goggles. Any suggestions?
NPC Code:
//#CLIENTSIDE
if(weaponfired && this.inuse==0)
{
this.inuse=1;
setstring client.infgoggles,1;
setplayerprop #P1,dr-hat008.png;
}
else if(weaponfired && this.inuse==1)
{
this.inuse=0;
setstring client.infgoggles,0;
setplayerprop #P1,;
seteffect 0,0,0,0;
hideimg 914775;
for(this.i=0;this.i<playerscount;this.i++)
{
hideimg this.i;
hideimg this.i+1;
}
timeout=0;
}
if(this.inuse==1 || timeout)
{
for(this.i=0;this.i=<playerscount;this.i++)
{
setstring client.players,#v(this.i);
showtext 914775,550,10,Arial,b,Players:#s(client.players);
changeimgzoom 914775,.5;
changeimgvis 914775,5;
showimg this.i,ion.gif,players[strtofloat(#s(client.players))].x+.5,players[strtofloat(#s(client.players))].y+.75;
changeimgcolors this.i,1,.25,.25,.99;
changeimgzoom this.i,2;
changeimgvis this.i,1;
}
timeout=.05;
}


napo_p2p 01-17-2006 11:45 PM

To get rid of it showing NPCs, in the for loop try checking to make sure the player's ID is > -1 (since 'character' NPC ids are -1). You can accomplish this by using:
PHP Code:

if (players[this.i].id > -1

NOTE: On a GS2 enabled server (and with v4), I do not think that NPCs are included in the players array.

As for your problem with a player seeing the light around himself, I believe that the first person in the players array (clientside) is yourself. So start the for loops at 1 (NOTE: I am not certain about this, but try if you are willing ;)).

Also, it's probably best to have only one if (weaponfired) block. For example:
PHP Code:

if (weaponfired) {
   if (
this.inuse == 0) {
     
//Stuff
   
}
   else {
     
//Stuff
   
}



excaliber7388 01-18-2006 12:07 AM

Quote:

Originally Posted by napo_p2p
To get rid of it showing NPCs, in the for loop try checking to make sure the player's ID is > -1 (since 'character' NPC ids are -1). You can accomplish this by using:
PHP Code:

if (players[this.i].id > -1

NOTE: On a GS2 enabled server (and with v4), I do not think that NPCs are included in the players array.

We are gs2 enabled, but I'll try that
Quote:

As for your problem with a player seeing the light around himself, I believe that the first person in the players array (clientside) is yourself. So start the for loops at 1 (NOTE: I am not certain about this, but try if you are willing ;)).
Eh, that would just make it so I couldn't see myself glowing
Quote:


Also, it's probably best to have only one if (weaponfired) block.
Got screwed up with the timeout x_X

napo_p2p 01-18-2006 12:18 AM

Quote:

Originally Posted by excaliber7388
Eh, that would just make it so I coulnd't see myself glowing...althought I'll try that too XD

Ahh I misunderstood what you meant. I thought you didn't want to show a glow around yourself.

But now I know what you mean. Use this.i + 300 (lower indexes are visible to all).

excaliber7388 01-18-2006 12:25 AM

Quote:

Originally Posted by napo_p2p
Ahh I misunderstood what you meant. I thought you didn't want to show a glow around yourself.

But now I know what you mean. Use this.i + 300 (lower indexes are visible to all).

But then that would be for a player with the index of 300? Also, when I try to add something in that accounts for the NPCs, I either get a ton of lag, or a negative number. this gets a negative #, but why?
NPC Code:
//#CLIENTSIDE
//stuff
if(this.inuse==1 || timeout)
{
for(this.i=0;this.i=<playerscount;this.i++)
{
setstring client.players,#v(this.i-this.n);
//stuff
else if(!players[strtofloat(#s(client.players))].id>-1 && this.i<playerscount)
{
this.n+=1;
}
//stuff
}


napo_p2p 01-18-2006 12:37 AM

Quote:

Originally Posted by excaliber7388
But then that would be for a player with the index of 300?

I'm sorry, I should have been more specific:

NPC Code:
    showimg this.i + 300,ion.gif,players[strtofloat(#s(client.players))].x+.5,players[strtofloat(#s(client.players))].y+.75;

changeimgcolors this.i + 300,1,.25,.25,.99;

changeimgzoom this.i + 300,2;

changeimgvis this.i + 300,1;


excaliber7388 01-18-2006 12:45 AM

:D Thanks, but I still can't get it to stop counting NPCs without going negative, i havn't changed the script I last posted, so far it's the one that gets closest, without a ton of lag

Yen 01-18-2006 02:14 AM

players[this.i].darts

NPCs normally don't carry around darts.

excaliber7388 01-18-2006 02:41 AM

huh? I don't need another thing to identify an NPC, the problem is, the weapon thinks that the NPC is included in playerscount, and therefore, it HAS to make this.i go up to that number, otherwise you have a never ending loop, with it being stuck at a number that may not be correct. I find that the NPC woeks in some levels, but not others, and the number is normally much higher than the actual number of NPCs in the level, (returning numbers like 600) what i need is for it to add 1 to a number each time it goes through the loop and finds an npc, then subtract that number from the playerscount (client.players) but when I try this, the loop becomes infinite, and the number becomes negative x_x

ZeLpH_MyStiK 01-18-2006 02:42 AM

have you actually seen infrared goggles? when you actually look into them, the image is green XD

excaliber7388 01-18-2006 02:45 AM

yeah, i should have called these thermal goggles, i plan to change the name. Anyway, I already have typical night vision gogles, this is an alternative, as night vision can be messed up by bright lights, and obstructions, like thick smoke, etc. whereas, this has a light that shows where each player is...and the number of players in the level, if I can fix that without lag x_X otherwise, I'll have to take it out.

Rick 01-18-2006 07:09 AM

PHP Code:

this.0;
for (
this.0this.=< playerscountthis.i++) {
  if (
players[this.i].id >= 0) {
    
showimg 300+this.j,ion.gif,players[this.i].x+.5,players[this.i].y+.75;
    
changeimgcolors 300+this.j,1,.25,.25,.99;
    
changeimgzoom 300+this.j,2;
    
changeimgvis 300+this.j,1;
    
this.j++;
  }



Draenin 01-25-2006 05:46 PM

My eyes! The goggles, they...
http://img.photobucket.com/albums/v3...ogglescard.jpg


All times are GMT +2. The time now is 10:40 AM.

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