Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Event Kick System Proplem (https://forums.graalonline.com/forums/showthread.php?t=134264641)

Nogross 09-25-2011 06:28 PM

Event Kick System Proplem
 
Hello Guys, I am it Nogross, and I have a little proplem.. I want to make a kick system which works in the specified Event level.. It don't work so please help me, it should work so:

ET says /kick - then he as to click a player and the player cordinates will be changed.
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/kick") {
    for (
temp.plplayers) {
      if (
mousex in temp.pl.xtemp.pl.| && mousey in temp.pl.ytemp.pl.| ) {
        
triggerserver("gui"name"KickPlayer"temp.pl);
      }
    }
  }

  function 
KickPlayer() {
    
player.30;
    
player.30;
  } 

I can't find the solution.. If it's very obviously or just nooby I am srry.

Thanks anyway!
NG

Emera 09-25-2011 06:34 PM

PHP Code:

// Where is the triggerserver?
//#CLIENTSIDE 

function onPlayerChats() {
  if (
player.chat == "/kick") {
    for (
temp.plplayers) {
      if (
mousex in temp.pl.xtemp.pl.| && mousey in temp.pl.ytemp.pl.| ) {
        
triggerserver("gui"name"KickPlayer"temp.pl);
      }
    }
  }
// Missed a brace.

function KickPlayer() {
  
player.30;
  
player.30;


The corrections I could make are in the script.

Nogross 09-25-2011 06:37 PM

Quote:

Originally Posted by Emera (Post 1669113)
PHP Code:

// Where is the triggerserver? 

The corrections I could make are in the script.

Thank you but how you mean that, // Where is the triggerserver?
It's the first time I do something with mouse so could you explain me that please ^.^ ?

Emera 09-25-2011 06:42 PM

Are you posting the full code?

You have a triggerserver in your code.
PHP Code:

triggerserver("gui"name"KickPlayer"temp.pl); 

Now, either you haven't posted that bit, or that just appeared from nowhere. Also, wouldn't it be easier to use a triggeraction instead? That's what I would do.

Nogross 09-25-2011 07:19 PM

It's the full code yes.. since I'm a really really new coder, I don't really know how to use it, I mean triggerserver. But could you explain me the triggeraction and how to use it? That would be great.

fowlplay4 09-25-2011 07:24 PM

I imagine this is what you're going for, I've re-factored your code below. You could create a class called:

events_commands

PHP Code:

function onCreated() {
  
// Gives your NPC shape on the server-side so 
  // triggeraction has something to hit.
  
this.setshape(13232);
}

function 
onActionKickPlayer() {
  
// Make sure the 'kicker' is on the Events Team
  
if (player.guild == "Events Team") {
    
// Get account from first parameter
    
temp.acc params[0];
    
// Kick account
    
kickPlayer(temp.acc); 
  }
}

function 
kickPlayer(acc) {
  
// Find Player
  
with (findplayer(acc)) {
    
// Kick/Relocate Player
    
player.30
    
player.30;
  }
}

//#CLIENTSIDE

function onPlayerChats() { 
  if (
player.chat == "/kick") { 
    for (
temp.plplayers) { 
      if (
mousex in temp.pl.xtemp.pl.| && mousey in temp.pl.ytemp.pl.| ) {
        
// To trigger level npcs you have to use triggeraction like this:
        // It will trigger onActionKickPlayer
        
triggeraction(this.1this.1"KickPlayer"temp.pl.account);
      } 
    } 
  } 


and place that in your event levels like this:

PHP Code:

function onCreated() {
  
join("event_commands");



Nogross 09-26-2011 12:16 AM

Thank you fowl, I learned much in youre code. Ty again. I understand all except the part with actionkickplayer wouldnt it be easier to add just a if (...) at func playerchats?

Emera 09-26-2011 12:22 AM

The kickplayer function you are wondering about is quite easy. It is a player made function primarily for that NPC. Example...
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
testing(); //Call the function
  // The players chat will change to Tested!
}

function 
Testing() { //Create the function
  
player.chat "Tested";


You can create you own functions for all sorts of purposes. Here you can see I have created the function Testing(). When the function is called, the players chat will change to Tested.

You can now use that function throughout your script.

Nogross 09-26-2011 12:34 AM

xD i know i meant something else... I dont understand why its not easier to add just a if (...) at the playerchat func

fowlplay4 09-26-2011 01:27 AM

Quote:

Originally Posted by Nogross (Post 1669155)
Thank you fowl, I learned much in youre code. Ty again. I understand all except the part with actionkickplayer wouldnt it be easier to add just a if (...) at func playerchats?

I guess you're referring to the Events Team guild check.

It should be on both (server and client) sides.

PHP Code:

// .. other code ..
function onActionKickPlayer() { 
  
// Make sure the 'kicker' is on the Events Team 
  
if (player.guild == "Events Team") {
    
// May help you understand what's happening better.
    
echo(player.account SPC "kicking" SPC params[0]);
    
// Kick
  
}
}

//#CLIENTSIDE

function onPlayerChats() {
  if (
player.guild == "Events Team") {
    if (
player.chat == "/kick") {
      
// .. other code ..
    
}
  }



Nogross 09-26-2011 04:56 PM

Quote:

Originally Posted by fowlplay4 (Post 1669160)
I guess you're referring to the Events Team guild check.

It should be on both (server and client) sides.

PHP Code:

// .. other code ..
function onActionKickPlayer() { 
  
// Make sure the 'kicker' is on the Events Team 
  
if (player.guild == "Events Team") {
    
// May help you understand what's happening better.
    
echo(player.account SPC "kicking" SPC params[0]);
    
// Kick
  
}
}

//#CLIENTSIDE

function onPlayerChats() {
  if (
player.guild == "Events Team") {
    if (
player.chat == "/kick") {
      
// .. other code ..
    
}
  }



Okay thanks I understand now all. Ty for youre help guys :)!

Twinny 09-26-2011 06:57 PM

Just to point out something obvious, you really should create an array of the players in mouse range first and do a single trigger with that array instead of a trigger for each player


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

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