Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Something Easy probably (https://forums.graalonline.com/forums/showthread.php?t=87864)

sssssssssss 09-11-2009 10:02 PM

Something Easy probably
 
PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe(){
  
this.checkregistry = (@ "serverr.registeredguilds" player.guild);
  if (
player.account in this.checkregistry){
    
this.chat "YO";
  }


i have certain guilds registered as
registeredguildsGUILDNAME

need to be able to check that array for each person that has on the tag and touches this, to see if they are in the guild that is registered. Im misisng something easy. I would rather use a temp. than a this. as it will change very often. Got it to show up on a this.chat only with it as a this.checkregistry though, wouldnt work in a temp.checkregistry

cbk1994 09-11-2009 10:04 PM

Why are you using serverr flags for that?

Besides that, I don't see anything wrong with the script.

xXziroXx 09-11-2009 10:12 PM

PHP Code:

this.checkregistry serverr.(@"registeredguilds" player.guild); 

:megaeek:

sssssssssss 09-11-2009 10:37 PM

man im dumb. thanks.

DustyPorViva 09-11-2009 10:42 PM

Quote:

Originally Posted by sssssssssss (Post 1522414)
man im dumb. thanks.

I have a hard time with concat'ing variables like that, too.

sssssssssss 09-11-2009 10:56 PM

ok, a little more into it now.
I have this on clientside

PHP Code:

temp.guildadd serverr.(@"registeredguilds" player.guild

then this serverside

PHP Code:

function onActionAddRegGuildServer(guildmember){
  
guild.add(member);


the guild param in the server action is the temp.guildadd, and the member is just a player account. trying to add the player account to the server array, just not adding in.

bleh, heres the entire thing
PHP Code:

function onCreated() {
  
this.setshape(13232);
}
function 
onActionRegistersdeServer(leader){
  
makevar("serverr.registeredguilds" player.guild) = {leader};
}
function 
onActionRegisterGuildServer(regguildregleader){
  
makevar("serverr.registeredguilds" regguild) = {regleader};
}
function 
onActionAddRegGuildServer(guildmember){
  
guild.add(member);
}
function 
onActionDelMemRegGuildServer(remove){
  
serverr.sdeaccess.remove(remove);
}
function 
onActionSetTagServer(tag){
  
player.guild tag;
}

//#CLIENTSIDE
function onCreated() {
  
this.setshape(13232);
}

function 
onPlayerChats() {
  if (
player.account == "sssssssssss" || "Decus_Arillias")
    {
    if (
player.chat == "registerguildsde")
      {
      if (
player.guild == ""){
        
say2("Put on guild tag first!");
      }else{
        
temp.owner "sssssssssss";
        
triggeraction(this.0.5this.0.5"RegistersdeServer"temp.owner);
      }
    }
    if (
player.chat.starts("registerguild"))
      {
      if (
player.guild == ""){
        
say2("Put on guild tag first!");
      }else{
        
temp.addguild player.chat.tokenize()[1];
        if (
player.guild == temp.addguild){
          
this.guildadd serverr.(@"registeredguilds" player.guild)
            
temp.add player.account;
          
triggeraction(this.0.5this.0.5"RegisterGuildServer"this.guildaddtemp.add);
        }
      }
    }
    if (
player.chat.starts("addmemberaccess")){
      if (
player.guild == ""){
        
say2("Put on guild tag first!");
      }else{
        
temp.addmemg player.chat.tokenize()[1];
        
temp.addmem player.chat.tokenize()[2];
        
triggeraction(this.0.5this.0.5"AddMemRegGuildServer"temp.addmemgtemp.addmem);
      }
    }
    if (
player.chat.starts("removeaccess"))
      {
      if (
player.guild == ""){
        
say2("Put on guild tag first!");
      }else{
        
temp.del player.chat.tokenize()[1];
        
triggeraction(this.0.5this.0.5"DelMemRegGuildServer"temp.del);
      }
    }
    if (
player.chat.starts("settag")){
      
temp.tag player.chat.tokenize()[1];
      
triggeraction(this.0.5this.0.5"SetTagServer"temp.tag);

    }
  }



xXziroXx 09-11-2009 11:19 PM

Uhm..

PHP Code:

function onActionAddRegGuildServer(guildmember){
  
serverr.(@"serverr.registeredguilds" guild).add(member);



Chompy 09-11-2009 11:21 PM

you should use triggerserver(), as I recall that to trigger to serverside with triggeraction() the action needs to be named "Serverside" or something like that. It was something like that, I might be wrong though.

cbk1994 09-11-2009 11:22 PM

Quote:

Originally Posted by Chompy (Post 1522430)
you should use triggerserver(), as I recall that to trigger to serverside with triggeraction() the action needs to be named "Serverside" or something like that. It was something like that, I might be wrong though.

If it starts with "Server" it triggers the Control-NPC, otherwise you have to use "ServerSide" (exception to previous statement) to trigger weapons, or anything else for NPCs (e.g. "Buy" would trigger "onActionBuy").

EDIT: There is absolutely no reason to use clientside in that script at all, though. It would be much more secure and efficient serverside.

sssssssssss 09-11-2009 11:38 PM

PHP Code:

function onActionAddRegGuildServer(guildmember){
  
serverr.(@"serverr.registeredguilds" guild).add(member);


already tried that too, didnt do anything

cbk1994 09-11-2009 11:41 PM

Quote:

Originally Posted by sssssssssss (Post 1522433)
PHP Code:

function onActionAddRegGuildServer(guildmember){
  
serverr.(@"serverr.registeredguilds" guild).add(member);


already tried that too, didnt do anything

Why not make the entire script serverside?

sssssssssss 09-12-2009 12:11 AM

That still wouldnt solve the problem, as what is required to be serverside is.

xXziroXx 09-12-2009 12:20 AM

My bad, typo. Use this:

PHP Code:

function onActionAddRegGuildServer(guildmember){
  
serverr.(@"registeredguilds" guild).add(member);



sssssssssss 09-12-2009 01:08 AM

cant believe i overlooked that, still nothing though

fowlplay4 09-12-2009 01:44 AM

Listen to cbk!

onPlayerChats() works serverside.

Thus you can use the playerchats code you already wrote on the clientside on the server-side

However instead of using triggeraction on the server-side make direct function calls. I.e: onAddMember(param1, param2)

sssssssssss 09-12-2009 01:48 AM

It still wouldnt change anything because it should still work this way too -_-

cbk1994 09-12-2009 02:50 AM

Quote:

Originally Posted by sssssssssss (Post 1522466)
It still wouldnt change anything because it should still work this way too -_-

Why would you want to do something the wrong way? You're obviously still learning GS2; you should take advice when it is given you.

Doing this clientside only makes it prone to "hackers" sending their own triggers, and also makes the script far less efficient.

fowlplay4 09-12-2009 02:55 AM

Oh yeah, you're also using guild as parameter name.

function onActionAddRegGuildServer(guild, member){
guild.add(member);
}

I've always had mixed results using variable names (in this case guild) that are generally taken by Graal.

sssssssssss 09-12-2009 03:13 AM

Quote:

Originally Posted by cbk1994 (Post 1522474)
Why would you want to do something the wrong way? You're obviously still learning GS2; you should take advice when it is given you.

Because Im really only worried on the matter at hand right now, and I know taking everything serverside will not fix the problem that started this thread. I do appreciate it, but I'm not very well on moving to another problem when there was already one I was facing. Trying to stay on topic is all.

Changed the param to guildzz still no use.

sssssssssss 09-12-2009 03:23 AM

omg. forgot to add "mem"in the action call. idiot i am


All times are GMT +2. The time now is 01:25 PM.

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