Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-06-2012, 04:24 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
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.
Reply With Quote
  #2  
Old 05-06-2012, 04:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #3  
Old 05-06-2012, 06:17 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
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
Reply With Quote
  #4  
Old 05-06-2012, 07:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Fysez View Post
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"); ?
__________________
Reply With Quote
  #5  
Old 05-06-2012, 07:53 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
As i said, I was using it as a test. It still doesn't work.
Reply With Quote
  #6  
Old 05-06-2012, 07:54 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Fysez View Post
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.
__________________
Reply With Quote
  #7  
Old 05-06-2012, 07:58 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Setting the sword power to 0 should be an easy hack to disable it, but definitely not recommended. Write a movement system.
Reply With Quote
  #8  
Old 05-06-2012, 08:42 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
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}
Reply With Quote
  #9  
Old 05-06-2012, 08:59 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
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.
__________________
Quote:
Reply With Quote
  #10  
Old 05-06-2012, 10:19 AM
Fysez Fysez is offline
Banned
Join Date: Apr 2012
Posts: 89
Fysez has a little shameless behaviour in the past
Quote:
Originally Posted by cbk1994 View Post
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 View Post
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.
Reply With Quote
  #11  
Old 05-06-2012, 06:48 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Fysez View Post
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 View Post
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 View Post
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.
__________________
Reply With Quote
  #12  
Old 05-06-2012, 06:49 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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""");
    }
  }

__________________
Quote:
Reply With Quote
  #13  
Old 05-06-2012, 06:55 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by fowlplay4 View Post
PHP Code:
if (keystring.upper() == keyname(4)) { 
You shouldn't need to uppercase the string here—do you? String comparisons are generally case-insensitive.
__________________
Reply With Quote
  #14  
Old 05-06-2012, 07:50 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
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
__________________
Quote:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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