Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   can soemone help me with this Basic Gun Script (https://forums.graalonline.com/forums/showthread.php?t=78450)

[email protected] 01-23-2008 04:04 PM

can soemone help me with this Basic Gun Script
 
:confused:

Script :



//#CLIENTSIDE
function onWeaponFired() {
if (this.on == false) {
this.on = true;
client.gani_idle = "light-old_rifle-idle";
onTimeout();
}
else{
this.on = false;
showsword(1);
player.chat = "Gun Deactivated!";
client.gani_idle = "idle";
client.gani_walk = "walk";
}
}
function onTimeout()
{
if (this.on == true)
{
hidesword(1);
player.chat = "Gun Activated!";
client.gani_idle = "light-old_rifle-idle";
client.gani_walk = "light-old_rifle-walk";
}
}
function onKeyPressed( code, key )
{
if ( key == "s" )
{
hidesword(1);
setani("light-old_rifle-fire", "");
freezeplayer(0.1);
setshootparams("Rifle", player.account);
shoot(player.x, player.y, 0, player.dir,0 ,0 , "utopia_bullet", "0.5");
}
}
function onPlayerChats(){
if (player.chat == "Reload"){
{
client.gani_idle = "light-old_rifle-reload";
sleep(0.25);
client.gani_idle = "light-old_rifle-idle";
}
}
}

Dan 01-23-2008 04:12 PM

Please use the PHP tags and style your scripting. This way it is easier to read through your script. Also tell us what exactly is wrong in your script.

(example of styling and using PHP tags)
PHP Code:

function onCreated() {
  
condition false;
  
stuffHere();
}

function 
stuffHere() {
  if (
condition) {
    
doMoreStuff();
  }
}

function 
doMoreStuff() {
  
condition = {"one","two"};



Tigairius 01-23-2008 05:42 PM

Could you please explain what's not working, what you're trying to get to, and as stated by Dan, use PHP tags?

[email protected] 01-23-2008 09:03 PM

Quote:

function onCreated() {
condition = false;
replaceani "walk","light-old_rifle-walk"();
replaceani "idle","light-old_rifle-idle"();
replaceani "sword","light-old_rifle-fire"();
}

function stuffHere() {
if (condition) {
replaceani "walk","walk"();
replaceani "idle","idle"();
replaceani "sword","sword"();
}
}

function doMoreStuff() {
condition = {"one","two"};
}
??

Dan 01-23-2008 09:48 PM

Proper styling
 
This one's better styled (how it should be);

PHP Code:

//#CLIENTSIDE
function onWeaponFired() {
  if (
this.on == false) {
    
this.on true;
    
client.gani_idle "light-old_rifle-idle";
    
onTimeout();
  }
  else{
    
this.on false;
    
showsword(1);
    
player.chat "Gun Deactivated!";
    
client.gani_idle "idle";
    
client.gani_walk "walk";
  }
}

function 
onTimeout() {
  if (
this.on == true) {
    
hidesword(1);
    
player.chat "Gun Activated!";
    
client.gani_idle "light-old_rifle-idle";
    
client.gani_walk "light-old_rifle-walk";
  }
}

function 
onKeyPressed(code,key) {
  if (
key == "s") {
    
hidesword(1);
    
setani("light-old_rifle-fire","");
    
freezeplayer(0.1);
    
setshootparams("Rifle",player.account);
    
shoot(player.x,player.y,0,player.dir,0,0,"utopia_bullet","0.5");
  }
}

function 
onPlayerChats(){
  if (
player.chat == "Reload"){
    
client.gani_idle "light-old_rifle-reload";
    
sleep(0.25);
    
client.gani_idle "light-old_rifle-idle";
  }


It looks like stuff from 4 different scripts though, lol.. and I personally never heard of hidesword and showsword either xD Did you just think of some commands that sound cool?

[email protected] 01-23-2008 09:48 PM

PHP Code:

function onCreated() {
condition false;
replaceani "walk","light-old_rifle-walk"();
replaceani "idle","light-old_rifle-idle"();
replaceani "sword","light-old_rifle-fire"();
}

function 
stuffHere() {
if (
condition) {
replaceani "walk","walk"();
replaceani "idle","idle"();
replaceani "sword","sword"();
}
}

function 
doMoreStuff() {
condition = {"one","two"};



NightmareNight 01-23-2008 10:50 PM

Quote:

Originally Posted by [email protected] (Post 1371523)
PHP Code:

function onCreated() {
condition false;
replaceani "walk","light-old_rifle-walk"();
replaceani "idle","light-old_rifle-idle"();
replaceani "sword","light-old_rifle-fire"();
}

function 
stuffHere() {
if (
condition) {
replaceani "walk","walk"();
replaceani "idle","idle"();
replaceani "sword","sword"();
}
}

function 
doMoreStuff() {
condition = {"one","two"};



Where did you get that from o.o?

Dan 01-23-2008 10:55 PM

Rofl, this thread is hilarious.

Inverness 01-23-2008 11:23 PM

God help you.

Function parameters go inside the parenthesis.

replaceani("idle", "mycustomani");

Twinny 01-23-2008 11:26 PM

You definitely have to be more specific....what about it doesn't work? Does the gun 'equip'? Shoot bullets which don't damage players? Doesn't shoot bullets? Spawns a ferret of mass unholy destruction which feasts on the sorrows of 7 2/6 year old children?

Also, do you actually work for Utopia or did you just 'source' this script without any understanding of it?

bscharff 01-24-2008 02:56 AM

Not from Utopia lol.
Chris made our gun system (Thanks again!)

MysticX2X 01-24-2008 03:42 PM

LOL he took Dans example of styling a bit too literal and tried to make a script of that.

Why is there a timeout to begin with :confused:

Bell 01-24-2008 06:57 PM

He came here asking for help, not to be insulted for trying to learn something. If he knew exactly what he was doing chances are he wouldn't be here to begin with.

zokemon 01-24-2008 07:19 PM

Quote:

Originally Posted by Dan (Post 1371522)
It looks like stuff from 4 different scripts though, lol.. and I personally never heard of hidesword and showsword either xD Did you just think of some commands that sound cool?

Hidesword was a command from gs1 made ages ago so you could literally, hide your sword (for a set time). With the appearance of ganis though, it's become very obsolete.

Inverness 01-25-2008 12:54 AM

Quote:

Originally Posted by Bell (Post 1371709)
He came here asking for help, not to be insulted for trying to learn something. If he knew exactly what he was doing chances are he wouldn't be here to begin with.

If I wanted to learn a new programming language I would find a tutorial and try to understand the basics, not take source code and try different combinations until it works or my computer doesn't. I would also be specific about what I wanted to know.

http://wiki.graal.net/index.php/GScript

If you want to learn how to script then read this.


All times are GMT +2. The time now is 09:17 AM.

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