Graal Forums

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

MattKan 03-02-2011 04:06 AM

MattKan scripting help
 
I'm trying to figure out how to make it so players can carry things.

When I pick up a sign or bush, I see that my gani becomes "carrystill". Since they are both the same, I assume there is a variable to decides the image name of the object the player is carrying. Is anyone familiar with the name of this variable?

oo_jazz_oo 03-02-2011 04:12 AM

I believe the player attribute for the carry image is player.attr[3].

So, if you did something like:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.attr[3] = "bomb.png";
  
replaceani("idle", "carrystill");
  
replaceani("walk", "carry");
} 

Your player would appear to be carrying a bomb. :P

callimuc 03-02-2011 01:17 PM

Quote:

Originally Posted by oo_jazz_oo (Post 1634010)
I believe the player attribute for the carry image is player.attr[3].

So, if you did something like:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.attr[3] = "bomb.png";
  
replaceani("idle", "carrystill");
  
replaceani("walk", "carry");
} 

Your player would appear to be carrying a bomb. :P

Well you won´t get out of it until you reconnect and the attribute will still be the bomb.png i guess ;)
I think you should do something like:
PHP Code:

//#CLIENTSIDE
function onWeaponFired(){
  if(
this.on = false){
    
this.on = true;
    
player.attr[3] = "bomb.png";
    
replaceani("idle", "carrystill");
    
replaceani("walk", "carry");
  }else{
    
this.on = false;
    
player.attr[3] = "";
    
replaceani("idle","idle");
    
replaceani("walk","walk");
  }
} 

Just got Trial again so I can´t test it :\

cbk1994 03-02-2011 01:55 PM

Quote:

Originally Posted by callimuc (Post 1634066)
Well you won´t get out of it until you reconnect and the attribute will still be the bomb.png i guess ;)
I think you should do something like:
PHP Code:

//#CLIENTSIDE
function onWeaponFired(){
  if(
this.on = false){
    
this.on = true;
    
player.attr[3] = "bomb.png";
    
replaceani("idle", "carrystill");
    
replaceani("walk", "carry");
  }else{
    
this.on = false;
    
player.attr[3] = "";
    
replaceani("idle","idle");
    
replaceani("walk","walk");
  }
} 

Just got Trial again so I can´t test it :\

Use == instead of = for value checking. A single equal sign is for assigning values for variables.

PHP Code:

//#CLIENTSIDE
function onWeaponFired(){
  if(
this.on == false){
    
this.on = true;
    
player.attr[3] = "bomb.png";
    
replaceani("idle", "carrystill");
    
replaceani("walk", "carry");
  }else{
    
this.on = false;
    
player.attr[3] = "";
    
replaceani("idle","idle");
    
replaceani("walk","walk");
  }
} 

In this case, you could also use

PHP Code:

if (! this.on) { 


callimuc 03-02-2011 08:44 PM

Quote:

Originally Posted by cbk1994 (Post 1634067)
Use == instead of = for value checking. A single equal sign is for assigning values for variables.

PHP Code:

//#CLIENTSIDE
function onWeaponFired(){
  if(
this.on == false){
    
this.on = true;
    
player.attr[3] = "bomb.png";
    
replaceani("idle", "carrystill");
    
replaceani("walk", "carry");
  }else{
    
this.on = false;
    
player.attr[3] = "";
    
replaceani("idle","idle");
    
replaceani("walk","walk");
  }
} 

In this case, you could also use

PHP Code:

if (! this.on) { 


whoops you right :P

oo_jazz_oo 03-02-2011 11:08 PM

I wasn't trying to give him a full working script. :P

I have no clue what hes using it for...so I showed him how to use it. ;p

MattKan 03-03-2011 12:24 AM

Quote:

Originally Posted by oo_jazz_oo (Post 1634010)
I believe the player attribute for the carry image is player.attr[3].

So, if you did something like:
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
player.attr[3] = "bomb.png";
  
replaceani("idle", "carrystill");
  
replaceani("walk", "carry");
} 

Your player would appear to be carrying a bomb. :P

Thanks :) and thanks to the other people too....

Does anyone know the gani name for dropping the attr[3] (ie throwing the bomb or bush on the ground)

MattKan 03-03-2011 12:52 AM

Oh, and on another note, (don't want to make an entirely different thread) how would I make music play from a url?

Soala 03-03-2011 12:55 AM

Quote:

Originally Posted by MattKan (Post 1634158)
Thanks :) and thanks to the other people too....

Does anyone know the gani name for dropping the attr[3] (ie throwing the bomb or bush on the ground)

You could do it by script. Check if the player's current gani is carry or carrystill and if grab key is pressed. Then revert the player's ganis to idle and walk and throw whatever he's carrying as attr[3] in the player's direction.

MattKan 03-03-2011 01:04 AM

Quote:

Originally Posted by Soala (Post 1634163)
You could do it by script. Check if the player's current gani is carry or carrystill and if grab key is pressed. Then revert the player's ganis to idle and walk and throw whatever he's carrying as attr[3] in the player's direction.

Yeah but is there a gani to throw what he's carrying?

DustyPorViva 03-03-2011 01:08 AM

There is no throw gani. There are only carry ganis and lifting, and lifting doesn't use player.attr[3] so you'd have to create a custom lift gani to use it.

MattKan 03-03-2011 01:36 AM

Quote:

Originally Posted by DustyPorViva (Post 1634168)
There is no throw gani. There are only carry ganis and lifting, and lifting doesn't use player.attr[3] so you'd have to create a custom lift gani to use it.

Oh ok. Thanks :)


All times are GMT +2. The time now is 03:53 PM.

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