Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Creative Corner (https://www.graalians.com/forums/forumdisplay.php?f=17)
-   -   John's Scripts (https://www.graalians.com/forums/showthread.php?t=9528)

Johnaudi 09-12-2012 11:08 AM

Quote:

Posted by Emera (Post 196688)
I'll happily buy you a month of it so you're able to sign up to those forums.

okay sure, I'll tell snk not giving me Gelats this month. Lol jk thanks for the offer but nah, I suppose Graal's official forums are dead and rare are the people who still go there.,,

xXziroXx 09-12-2012 12:36 PM

Quote:

Posted by Johnaudi (Post 196707)
Graal's official forums are dead and rare are the people who still go there.,,

This is not true at all, and is a common misconception by the people who use Graalians.

Johnaudi 09-18-2012 07:45 AM

Alright so another thing, is there a way to get a list of all players in a guild? I did try
PHP Code:

for (temp.iallplayers) {
  if (
temp.== "Guild") {
    
temp.findplayerbycommunityname(temp.i);
    echo(
temp.a);
  }


It's just giving me one member with the tag on... Any other ideas how I can set them in an array?

Kavan 09-18-2012 04:29 PM

Quote:

Posted by Johnaudi (Post 200237)
Alright so another thing, is there a way to get a list of all players in a guild? I did try
PHP Code:

for (temp.iallplayers) {
  if (
temp.== "Guild") {
    
temp.findplayerbycommunityname(temp.i);
    echo(
temp.a);
  }


It's just giving me one member with the tag on... Any other ideas how I can set them in an array?

PHP Code:

for(temp.pl allplayers) {
  if(
temp.pl == "Guild" && temp.pl.level != NULL) {
    
temp.array[temp.playerCount] = findPlayerByCommunityName(temp.pl);
    
temp.playerCount ++;
  }
}
echo(
temp.array); 

Hopefully that should work as intended.

Tricxta 09-19-2012 02:20 AM

I really don't get you guys, you're saying is this player object equivalent to "guild"

it should be:
PHP Code:

for (temp.pl allplayers){
  if (
temp.pl.guild == "guild" && temp.pl.level != NULL){
    
temp.array[temp.playerCount] = findPlayerByCommunityName(temp.pl); 
    
temp.playerCount ++; 
  }



Johnaudi 09-19-2012 07:29 AM

Difference? "guild" was just an example - thanks guys :)

Johnaudi 09-19-2012 09:22 PM

Alright, so today I asked snk how do player.onHP() work... I got the major idea about it, I am still wondering of: how do they set the params about it? Let's say player.onHP(-50); would they have something like if (params[0] == "-50") or is there another way?

callimuc 09-19-2012 09:44 PM

Quote:

Posted by Johnaudi (Post 201045)
Alright, so today I asked snk how do player.onHP() work... I got the major idea about it, I am still wondering of: how do they set the params about it? Let's say player.onHP(-50); would they have something like if (params[0] == "-50") or is there another way?

you should keep custom commands from iEra intern. anyway, lets say you have something like

PHP Code:

onDoDamage(50); 

than you could remove the damage (depending on the system you use) like this
PHP Code:

public function onDoDamage(dmg) {
  if (
clientr.health_cur == 0) return;
  
temp.damage max(dmg0); //use max() to avoid positive damage (healing)
  
if (clientr.health_cur damage 0clientr.health_cur -= damage;
  else if (
clientr.health_cur dmg >= 0) {
    
clientr.health_cur 0;
    
onRevivePlayer();
  }
}

function 
onRevivePlayer() {
  
//add a revive gani or whatever you want to have
  
clientr.health clientr.health_max;


and to add damage you would simply use such a function
PHP Code:

public function onAddDamage(dmg) {
  if (
clientr.health_cur == clientr.health_max) return;
  
clientr.health_cur min(clientr.health_maxclientr.health_cur+dmg); //use min() to avoid negative damage


you can also change it so you can add and remove damage within one function. that could look like
PHP Code:

onDamage(somedamagehere);

function 
onDamage(dmg) {
  
clientr.health_cur -= dmg;
  
/*
  in case you are not that familiar with maths:
  if the dmg is positive, its adding the damage (hurt) with the -
  but if the damage is negative, its returning in the "negative and negative = positive" rule in maths
  */
  
if (clientr.health_cur clientr.health_maxclientr.health_cur clientr.health_max;
  else if (
clientr.health_cur =< 0onRevivePlayer();
}

function 
onRevivePlayer() {
  
//add some stuff like a revive gani or whatever you want to have
  
clientr.health_cur clientr.health_max;



this is pretty barebone. you would be on your best way by joining the player to a class so you can call the functions with player.yourFunction() rather than with triggering the server or any other stuff.

Johnaudi 09-30-2012 06:40 AM

Okay thanks guys, another thing. I have made 2 scripts with findimg() and I want them both in the same Weapon, any way to do that?

Tricxta 09-30-2012 06:42 AM

Quote:

Posted by Johnaudi (Post 206362)
Okay thanks guys, another thing. I have made 2 scripts with findimg() and I want them both in the same Weapon, any way to do that?

uhmm what?

Johnaudi 09-30-2012 06:52 AM

So okay, I got those two scripts :
PHP Code:

function onActionServerSide() {
  if (
params[0] == "mouse") {
    
temp.ix params[1];
    
temp.iy params[2];
    for (
temp.allplayers) {
      if (
temp.ix in |temp.p.1temp.p.3| && temp.iy in |temp.p.ytemp.p.3|) {
        
temp.p.chat "I've been shot!";
        
temp.p.onHP(-9);
      }
    }
  }
}
//#CLIENTSIDE
function onCreated() {
  
thiso."iera-callimuc_sniper-crosshair.png";
  
thiso.32;
}
function 
onPlayerChats() {
  if (
player.chat == "rooton") {
    
thiso.bool true;
    
setTimer(0.1);
  }
  if (
player.chat == "rootoff") {
    
thiso.bool false;
    
setTimer(0.01);
  }
}
function 
onMouseDown(mode) {
  if (
mode == "right") {
    if (
thiso.bool true)
      
triggerserver("gui"name"mouse",mousex,mousey);
  }
}
function 
onTimeOut() {
  
with (findimg(199)) {
    
image = (thiso.boolthiso."");
    
mousex 1.40;
    
mousey 1.40;
    if (
mousex player.x) {
      
thiso.= (mousex - (player.1)) / thiso.q;
    } else
    if (
mousex player.x) {
      
thiso.= (+ (player.1) - mousex) / thiso.q;
    }
    if (
mousey player.y) {
      
thiso.= (mousey - (player.1)) / thiso.q;
    } else
    if (
mousey player.y) {
      
thiso.= (+ (player.1) - mousey) / thiso.q;
    }
    
zoom  = ((thiso.thiso.u) >= ? (thiso.thiso.u) = : (thiso.thiso.u));
    
layer 3;
    
spin  = -3;
  }
  
setTimer(random(0.01,0.04));


PHP Code:

//#CLIENTSIDE
function onCreated() {
  
thiso."iera-callimuc_sniper-crosshair.png";
  
thiso.15;
}
function 
onPlayerChats() {
  if (
player.chat == "rooton") {
    
thiso.bool true;
    
setTimer(0.1);
  }
  if (
player.chat == "rootoff") {
    
thiso.bool false;
    
setTimer(0.01);
  }
}
function 
onTimeOut() {
  
with (findimg(199)) {
    
image = (thiso.boolthiso."");
    
mousex 1.40;
    
mousey 1.40;
    if (
mousex player.x) {
      
thiso.= (mousex - (player.1)) / thiso.q;
    } else
    if (
mousex player.x) {
      
thiso.= (+ (player.1) - mousex) / thiso.q;
    }
    if (
mousey player.y) {
      
thiso.= (mousey - (player.1)) / thiso.q;
    } else
    if (
mousey player.y) {
      
thiso.= (+ (player.1) - mousey) / thiso.q;
    }
    
zoom  = ((thiso.thiso.u) >= ? (thiso.thiso.u) = : (thiso.thiso.u));
    
layer 3;
    
spin  2;
  }
  
setTimer(random(0.01,0.04));


is there a way to match them in one?

Oh and if there is any way to make the player's dir follow the mouse coordinates would help too :(
Can't seem to make them change on both X and Y.

Tricxta 09-30-2012 07:54 AM

Okay so you'll just have to copy and paste things into one weapon while watching out for clashes in indexes and variable names, bit of a no brainer tbh...

Also with having the player direction follow your mouse you could just do:
PHP Code:

player.dir = (int((pi*2-getangle(mousex-player.x,player.y-mousey)+(pi/4))/(pi/2))+3)%4

and place it in a timeout loop.

There was a function that works that out as well but I can never remember it...

Johnaudi 09-30-2012 08:04 AM

will there be a difference with
PHP Code:

player.dir getdir(mousex player.1.5mousey player.1.5); 

and yours? Pix just told me about it

Tricxta 09-30-2012 08:48 AM

Quote:

Posted by Johnaudi (Post 206394)
will there be a difference with
PHP Code:

player.dir getdir(mousex player.1.5mousey player.1.5); 

and yours? Pix just told me about it

Yer, there'll be no difference. I just can't remember that function since I use gs1 mostly.

callimuc 09-30-2012 12:58 PM

Quote:

Posted by Johnaudi (Post 206368)
-scripts-

why did you use thiso.flags?

you only have to use it outside of the with() function if you are regarding it to a this.flag outside of the with() function. like

PHP Code:

function onCreated() {
  
this.whatever "hi";
  
with(findPlayer("callimuc")) {
    
chat thiso.whatever;
    
nick thiso.whatever;
  }


this.flag inside the with() function would attribute to the stuff inside the with() function (in this case the findPlayer("callimuc")


ps: what kind of sniper are you trying to do o.O just looks like a random crosshair being shown somewhere with a laggy player check :P


All times are GMT. The time now is 02:11 PM.

Powered by vBulletin/Copyright ©2000 - 2025, vBulletin Solutions Inc.