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 02-03-2011, 02:37 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
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!");
    }
  }

Reply With Quote
  #2  
Old 02-03-2011, 02:48 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Starfire2001 View Post
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.
Reply With Quote
  #3  
Old 02-03-2011, 05:12 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Thanks! Was able to figure it out from that!
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 02:55 PM.


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