Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Event Player Counter (https://forums.graalonline.com/forums/showthread.php?t=134261936)

Starfire2001 02-03-2011 02:37 AM

Event Player Counter
 
I'm attempting to make a player counter for an events I'm making. It works fine up till the end, in which I want to display the winning players name. Instead of doing that it seems to be just picking a person at random from the server and saying they win. Anyways, I'm pretty much completely new to scripting, started like 5 days ago, and I can't figure out what the problem could be. Any and all help would be appreciated. :(

PHP Code:

function onPlayerDies(pl){
  
temp.cot = -1;
  for (
temp.pl players) {
    if (
temp.pl.level.name == player.level.name){
      if (
pl.guild == "Events Team") {
        continue;
      }
      
cot ++;
    }
  }
  if (
cot == 1){
    
this.start 0;
    
setTimer(1);
  }
  else {
    
message(cot SPC "players left!");
  }
}
function 
onTimeout(){
  for (
temp.plallplayers)  {
    if (
temp.pl.level.name == player.level.name){
      if (
pl.guild == "Events Team") {
        continue;
      }
      
message(temp.pl.communityname SPC "wins!");
    }
  }



ffcmike 02-03-2011 02:48 AM

Quote:

Originally Posted by Starfire2001 (Post 1627479)
I'm attempting to make a player counter for an events I'm making. It works fine up till the end, in which I want to display the winning players name. Instead of doing that it seems to be just picking a person at random from the server and saying they win. Anyways, I'm pretty much completely new to scripting, started like 5 days ago, and I can't figure out what the problem could be. Any and all help would be appreciated. :(

PHP Code:

function onPlayerDies(pl){
  
temp.cot = -1;
  for (
temp.pl players) {
    if (
temp.pl.level.name == player.level.name){
      if (
pl.guild == "Events Team") {
        continue;
      }
      
cot ++;
    }
  }
  if (
cot == 1){
    
this.start 0;
    
setTimer(1);
  }
  else {
    
message(cot SPC "players left!");
  }
}
function 
onTimeout(){
  for (
temp.plallplayers)  {
    if (
temp.pl.level.name == player.level.name){
      if (
pl.guild == "Events Team") {
        continue;
      }
      
message(temp.pl.communityname SPC "wins!");
    }
  }



First of all you have "pl" as the parameter of the onPlayerDies function aswell as within the for loop, I've never really used onPlayerDies as it's a default function but if that parameter is necessary and the player object is not that of the player which just died you'd need to be using the specified param name, which in this case would be a conflict.

Message serverside within the timeout is not something that needs to be done for every single player, calling it just once should work fine, the fact that you are looping through allplayers is why it would be selecting a random player from the server, you need to be checking the normal players array from that level again assuming that the player object is not valid, albeit it's not really necessary due to the previous point.

Starfire2001 02-03-2011 05:12 AM

Thanks! Was able to figure it out from that!


All times are GMT +2. The time now is 08:34 PM.

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