Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Triggering a function from a weapon on another player. (https://forums.graalonline.com/forums/showthread.php?t=134260458)

Jiroxys7 09-07-2010 01:41 AM

Triggering a function from a weapon on another player.
 
Alrighty, so I'm doing, in an onActionServerSide() of course:


PHP Code:

with(findplayer(acctnameblah)){
  
BuffSystem.addbuff("nameblah","stuffblah","etc");
} 

now the problem is that it seems to apply for only a split second. but nothing will actually go through to their flags. same thing if i just try to send player.chat = "!"; in this way.

Doesn't make any sense. The script looks like it would make perfect sense, yet it's not working. What's the problem here?

adam 09-07-2010 02:16 AM

If it does trigger the weapon on the other client, perhaps you need to check your BuffSystem's addbuff function script?

Jiroxys7 09-07-2010 02:28 AM

edit: when I try my script, it gives me a syntax error
Function BuffSystem.addbuff not found at line 4 in script of <weapon name etc etc>

I ran into this before but I didnt think this was happening in this variation because I had been messing around with things like tagging the findplayer thing in front of Buffsystem, as well as using findweapon, so i didnt bother to post it.

And the player chat thing seems to work now, so i guess that's not the problem anymore.

So yeah, I dont get why this syntax error should be occuring. the small block of code seems to make perfect sense. instead of triggering the buff to yourself, find another player and trigger it on them. right?

Cubical 09-07-2010 03:30 AM

Quote:

Originally Posted by Jiroxys7 (Post 1599312)
edit: when I try my script, it gives me a syntax error
Function BuffSystem.addbuff not found at line 4 in script of <weapon name etc etc>

I ran into this before but I didnt think this was happening in this variation because I had been messing around with things like tagging the findplayer thing in front of Buffsystem, as well as using findweapon, so i didnt bother to post it.

And the player chat thing seems to work now, so i guess that's not the problem anymore.

So yeah, I dont get why this syntax error should be occuring. the small block of code seems to make perfect sense. instead of triggering the buff to yourself, find another player and trigger it on them. right?

post it

Jiroxys7 09-07-2010 03:32 AM

Here's the block of code causing the problem.

PHP Code:

function onActionServerSide(cmd, target){
  if(
cmd == "spite"){
    
with(findplayer(target)){
      
BuffSystem.addbuff("Spite", 30, "cannotstack", -10);
    }
  }
} 

Then when that part of the script goes through, I'll immediately get the following in rc:

Script: Function BuffSystem.addbuff not found at line 4 in script of -Skills/Spite (in level onlinestartlocal.nw at pos (0, 0))

fowlplay4 09-07-2010 04:32 AM

BuffSystem doesn't exist then, also you should add AddBuff as a server-side player function so u can do fun things like...

player.addBuff() or for (temp.p: allplayers) temp.p.addBuff().

MrOmega 09-07-2010 05:24 AM

You may want to try Findweapon() for triggering a public function in the other weapon

Cubical 09-07-2010 05:34 AM

putting it in a class and then joining it to the player is a much better idea in my opinion. Also I prefer using something along the lines of this instead of findWeapon();.
PHP Code:

(@"Systems/mainSystem").addBuff(); 

It's a personal preference however I'm not sure if it's any more or less efficient than findWeapon().

MrOmega 09-07-2010 05:45 AM

I agree with the class method, but I perfered to use findweapon() so I know what I'm referencing. :p

Jiroxys7 09-07-2010 06:03 AM

well actually, BuffSystem is a class joined to a mod system weapon. (the buff system class is headed with BuffSystem = this; in it's onCreated())

and the function addbuff is, of course, a public function. and @ cubical, i thought if you joined a class to a player, you can only call player functions? (which apparently arent custom-named functions and therefore wouldnt work, right?)

Cubical 09-07-2010 06:38 AM

Quote:

Originally Posted by Jiroxys7 (Post 1599370)
well actually, BuffSystem is a class joined to a mod system weapon. (the buff system class is headed with BuffSystem = this; in it's onCreated())

and the function addbuff is, of course, a public function. and @ cubical, i thought if you joined a class to a player, you can only call player functions? (which apparently arent custom-named functions and therefore wouldnt work, right?)

PHP Code:

player.join("blah");
player.addBuff("demonize"); 


Jiroxys7 09-07-2010 06:42 AM

Quote:

Originally Posted by Cubical (Post 1599378)
PHP Code:

player.join("blah");
player.addBuff("demonize"); 


of course. "player functions". it all makes sense now. /facepalm. thanks I'll try it out tomorrow.

Jiroxys7 09-09-2010 12:49 AM

Wall of text:

Alright, I was starting on joining it to the player on the server-side, but i quickly realized that I would probably have to essentially redo my entire system. So instead, I had the weapon send the serverside command/function over to the mod system weapon. which handles the buff system class. from there, it takes the data from the serverside and does a triggerclient to send it over to the clientside. I would have sent it directly to the class and done that, but of course, for whatever reason, you're not able to send serverside<->clientside triggers in classes. so instead, from there, i then send it over to the class. using this method, i can clientside the entire process unless a serverside trigger is required (i.e. findplayer). Which should help reduce server strain in the long run. even if it's by a small amount. compared to serversiding most of it.

Quote:

Originally Posted by MrOmega (Post 1599366)
I agree with the class method, but I perfered to use findweapon() so I know what I'm referencing. :p

I prefer my method. not only is there less typing, but, if done properly, will give you all the information you need at a glance. for example, to solve your problem, the system i have to handle my weapon data is called -Serverfunctions/-WeaponSystem. I then put WeaponSystem = this; in the onCreated function, so that way, when i see WeaponSystem.blah(blah,blah), I know that's it's sending data to my weapon system because it's easily identifiable that way. and in this case, BuffSystem (the class is called buffsystem), if I see BuffSystem.addbuff(blah) i know exactly what the script is doing. using the buff system to add a buff, of course :p



ANYWAY
Now that I have this, for the most part, working, I have one more related issue that I've been having trouble with lately. It seems that my ModSystem (the weapon joined to buffsystem) won't apply any buff effects to anyone who has just logged in. this problem is resolved once i open up the weapon, and click "Apply" after they've logged in. And I need to repeat this every time a player logs in... So does anyone have any idea what might be the culprit? is there any built in function to update the weapon so i can put it in an onCreated or something, instead of doing this process every time?

edit: nvm i managed to fix this by doing player.ModSystem.onCreated() in the control npc when the player logs in. still dont know why i had to do this though.

cbk1994 09-09-2010 12:52 AM

Use player classes & functions. It may require some refactoring but it's worth it.

Jiroxys7 09-09-2010 01:43 AM

Quote:

Originally Posted by cbk1994 (Post 1599693)
Use player classes & functions. It may require some refactoring but it's worth it.

Any benefits in specific? I've been working on the buff & mod system for quite some time now. and now that things are at least working, I want to move on in development until i run into a situation that really calls for the system to be redone.


All times are GMT +2. The time now is 07:03 AM.

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