Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Disabling Classic-Style swords? (https://forums.graalonline.com/forums/showthread.php?t=134266378)

Fysez 05-06-2012 04:24 AM

Disabling Classic-Style swords?
 
Alright so, I want to disable Classic-Like swords on my server.
Example: Era. They have guns and when you click S, a sword doesn't hit.

I want my server like that because I have future plans for different weapons.
I want it so you can kill, and get hurt, and everything. Just disable the whole S for sword thing. I'm not sure if it would go into server options or not,
So that's what I need help figuring out as well.

P.N. I would have looked it up, But I have no idea how to briefly explain it.

cbk1994 05-06-2012 04:55 AM

Era uses a custom movement system.

You can disable the sword with something like replaceani("sword", "idle"); but I'm not sure that this is still the preferred way as it has some unintended consequences.

Fysez 05-06-2012 06:17 AM

Using that, I tried it as a test run under weapons. But it doesn't seem to work?:

function onWeaponFired() {
if (weaponfired) {
setani("swim");
replaceani("idle","swim");
replaceani("walk","swim");
}
}

Doesn't work o.o

cbk1994 05-06-2012 07:17 AM

Quote:

Originally Posted by Fysez (Post 1693776)
Using that, I tried it as a test run under weapons. But it doesn't seem to work?:

function onWeaponFired() {
if (weaponfired) {
setani("swim");
replaceani("idle","swim");
replaceani("walk","swim");
}
}

Doesn't work o.o

Probably because you're not using replaceani("sword", "idle"); ?

Fysez 05-06-2012 07:53 AM

As i said, I was using it as a test. It still doesn't work.

cbk1994 05-06-2012 07:54 AM

Quote:

Originally Posted by Fysez (Post 1693778)
As i said, I was using it as a test. It still doesn't work.

What are you trying to do? You can't just put in arbitrary GANI names and expect it to disable the sword.

Hezzy002 05-06-2012 07:58 AM

Setting the sword power to 0 should be an easy hack to disable it, but definitely not recommended. Write a movement system.

Fysez 05-06-2012 08:42 AM

CBK,
I think i've listed quite clearly now that the script I listed was a test,
Not the actual thing to disable since it doesn't even work anyways.
All I need is how to fix the script I have listed. From there, I can work my own way towards disabling swords.
Get it not?{o}.{o}

fowlplay4 05-06-2012 08:59 AM

Quote:

Originally Posted by cbk1994 (Post 1693774)
replaceani("sword", "idle"); but I'm not sure that this is still the preferred way as it has some unintended consequences.

That will make idle players and NPCs "hurt" you if you walk into them, it's completely unnecessary to do though. You can also stick with default movement as well.

On Zodiac we use this (to disable nearly everything):

-System:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showstats(1024);
  
enablefeatures(allfeatures-1-2-4-8-0x100-0x200-0x400-0x800-0x2000-0x40-0x10-0x20);
  
disableselectweapons();
  
disableweapons();


Documentation:
http://wiki.graal.net/index.php/Enablefeatures
http://wiki.graal.net/index.php/Showstats

Then we have custom systems to trigger WeaponFired/Cast on weapons.

Fysez 05-06-2012 10:19 AM

Quote:

Originally Posted by cbk1994 (Post 1693774)
Era uses a custom movement system.

You can disable the sword with something like replaceani("sword", "idle"); but I'm not sure that this is still the preferred way as it has some unintended consequences.

Quote:

Originally Posted by fowlplay4 (Post 1693782)
That will make idle players and NPCs "hurt" you if you walk into them, it's completely unnecessary to do though. You can also stick with default movement as well.

On Zodiac we use this (to disable nearly everything):

-System:

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showstats(1024);
  
enablefeatures(allfeatures-1-2-4-8-0x100-0x200-0x400-0x800-0x2000-0x40-0x10-0x20);
  
disableselectweapons();
  
disableweapons();


Documentation:
http://wiki.graal.net/index.php/Enablefeatures
http://wiki.graal.net/index.php/Showstats

Then we have custom systems to trigger WeaponFired/Cast on weapons.

Hey! Thanks so much! That helped! Now there is one other problem I can't seem to figure out..

//#CLIENTSIDE
function onCreated() {
showstats(0x200); //Inventory NPC's
enablefeatures(allfeatures-4); // Disabled S and D
disableweapons();
}

The problem is, Now I can't use my inventory (Q) and I can't use items (D)
Would you know how to fix this? I've been looking into it but can't seem to figure it out.

cbk1994 05-06-2012 06:48 PM

Quote:

Originally Posted by Fysez (Post 1693781)
CBK,
I think i've listed quite clearly now that the script I listed was a test,
Not the actual thing to disable since it doesn't even work anyways.
All I need is how to fix the script I have listed. From there, I can work my own way towards disabling swords.
Get it not?{o}.{o}

No, it wasn't clear what you were saying:

Quote:

Originally Posted by Fysez (Post 1693776)
Using that, I tried it as a test run under weapons. But it doesn't seem to work?:

We can't guess what you're trying to say. The code isn't working for a few reasons:
  • You don't need an "if (weaponfired)" inside an onWeaponFired event; the former is a GS1 remnant that should never be used.
  • setani requires two parameters, e.g. setAni("swim", null);
  • Make sure it's clientside if it's not already.

Quote:

Originally Posted by Fysez (Post 1693784)
The problem is, Now I can't use my inventory (Q) and I can't use items (D)
Would you know how to fix this? I've been looking into it but can't seem to figure it out.

For firing weapons, you need to add something like this somewhere, clientside:

PHP Code:

function GraalControl.onKeyDown(temp.codetemp.key) {
  if (
temp.key == "d" && ! this.keyD) {
    
player.weapon.trigger("weaponFired"); // v6 only, add another parameter to support v5
    
this.keyD true;
  }
}

function 
GraalControl.onKeyUp(temp.codetemp.key) {
  if (
temp.key == "d") {
    
this.keyD false;
  }


edit: use the code Jer posted; his is preferable since it allows players to set their own keys

Put that in some system weapon that all players have.

To enable Q (not positive if it works when weapons are disabled—test it), don't remove it from "allfeatures" in your enablefeatures. See here.

fowlplay4 05-06-2012 06:49 PM

Put your code in PHP tags.

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showstats(0x200 0x400 +  0x800); // Shows only ASD, Inventory NPCs, Players, Profiles
  
enablefeatures(allfeatures 0x20// Enables all features except S + D key combination
}

// You can simulate onWeaponFired like this:
function GraalControl.onKeyDown(keycodekeystringscancode) {
  
// Make sure the player isn't frozen
  
if (player.freezetime 0) { 
    
// Make sure they used the default weapon key
    
if (keystring.upper() == keyname(4)) {
      
// Trigger onWeaponFired on currently selected weapon
      
player.weapon.trigger("WeaponFired""");
    }
  }



cbk1994 05-06-2012 06:55 PM

Quote:

Originally Posted by fowlplay4 (Post 1693812)
PHP Code:

if (keystring.upper() == keyname(4)) { 


You shouldn't need to uppercase the string here—do you? String comparisons are generally case-insensitive.

fowlplay4 05-06-2012 07:50 PM

Quote:

Originally Posted by cbk1994 (Post 1693814)
You shouldn't need to uppercase the string here—do you? String comparisons are generally case-insensitive.

So they are... echo(("d A" == "D a")); // echos 1


All times are GMT +2. The time now is 02:31 PM.

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