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 12-29-2007, 01:20 PM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan is on a distinguished road
Graal Improvement Script: Vote System for Staff Priorities

This thread is for a Graal Improvement Script - a script that is freely distributed for any server to use (its creators credited of course ) for the general improvement of Graal servers.

The NPC I would like assistance to script is illustrated in the attached image. If any of you have ever used Dreamhost, you will be familiar with the concept.

Summary:

A player gets X ammount of vote points to spend.

Suggestions are moderated by the staff and managed through a GUI. Access control to this will be set at the top of the script so servers can customize the staff detection to their current systems. (Ie, if player has a staff flag, or is in serverops, or a certain accounts list, etc.)

Once a suggestion is added a player can spend their points to vote For or Against (+ or -) on a suggestion. The suggestion's rank is then calculated by tallying the For votes and subtracting the Against votes to give you the # of player points contributed to this suggestion by popular opinion.

Example:

HTML Code:
Move fishing house closer to unstick me?   +  24  -
Move fishing house closer to jail?         +  2   -
Move fishing house closer to faraway town? +  -8  -
Suggestions are then displayed in the suggestion tracker by the current rank, positive at the top. Any suggestion you spend points on is "stickied" at the top, so you can easily manage the points you are using and where.

If a suggestion is removed from the list, you regain those points to use elsewhere. You can remove or add points at any time as long as your total votes are less than the X number of points you have to spend.

You'll see in the image below the Dreamhost system has different "costs" for votes on different things (they decide the cost of a vote based on the difficulty of implementing the idea). For our purposes, the costs will all initially be 1. (Ie, a vote costs 1 point.) It would be nice to add that feature in the future, but I'd really like to get a working version of this deployed ASAP

Thank you in advance for the time put into this idea, your names will be credited in the script. You may also add a tasteful credit for players to see, be it an "About" button, or a small blurb somewhere saying "Created by ____"

Collaborate! I don't want anybody bearing the whole load on these
Also, if I've been unclear on anything just ask
Attached Thumbnails
Click image for larger version

Name:	dreamhost.jpg
Views:	238
Size:	462.0 KB
ID:	43631   Click image for larger version

Name:	GIS-votesys.png
Views:	233
Size:	16.6 KB
ID:	43632  
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #2  
Old 12-29-2007, 03:43 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Goood luck, I wish I could help, but at the moment I don't have a computer, and I'm not going to try scripting on a phone
__________________
Reply With Quote
  #3  
Old 12-29-2007, 10:08 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Can't you just have a browser-version of it? Having Dreamhost or whatever manage it already instead of having it as an in-game version of it... Maybe if in-game is so important, have a browser in the game.

Way I see it is it's merely just reinventing the wheel.
Reply With Quote
  #4  
Old 12-29-2007, 10:21 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by Novo View Post
Can't you just have a browser-version of it? Having Dreamhost or whatever manage it already instead of having it as an in-game version of it... Maybe if in-game is so important, have a browser in the game.

Way I see it is it's merely just reinventing the wheel.
There is a browser in game, and a computer to use with it, you can send email to anyone server.... *goes off on a tangent* :P
__________________
Deep into the Darkness peering...
Reply With Quote
  #5  
Old 12-30-2007, 12:47 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Quote:
Originally Posted by Novo View Post
Can't you just have a browser-version of it? Having Dreamhost or whatever manage it already instead of having it as an in-game version of it... Maybe if in-game is so important, have a browser in the game.

Way I see it is it's merely just reinventing the wheel.
yeah, why make new games, i mean, we could just take parts of other games :P

oh wait, they already do this
Reply With Quote
  #6  
Old 12-30-2007, 12:59 AM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan is on a distinguished road
Quote:
Originally Posted by cbkbud View Post
Goood luck, I wish I could help, but at the moment I don't have a computer, and I'm not going to try scripting on a phone
How long till you get back online? It seems like nobody else is interested in helping out.
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #7  
Old 12-30-2007, 01:21 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Quote:
Originally Posted by HoudiniMan View Post
How long till you get back online? It seems like nobody else is interested in helping out.
well i already started, but i'm kinda stuck with array sorting x.x
__________________

Last edited by projectigi; 12-31-2007 at 12:39 AM..
Reply With Quote
  #8  
Old 12-30-2007, 11:29 PM
trevor987 trevor987 is offline
Registered User
Join Date: Jun 2007
Posts: 20
trevor987 is on a distinguished road
This script would be pretty useful to have for replacing the common Yes/No or multiple choice voting system. Right now things are somewhat busy with the server I work on, but I'll try to start playing around with something soon.
Reply With Quote
  #9  
Old 01-01-2008, 05:07 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
I'm working on it right now ;o

I think I might be done later today tho, maybe
__________________
Reply With Quote
  #10  
Old 01-01-2008, 11:12 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
well, I would be already done, but the script compiler hates me XD so good luck chompy
__________________
Reply With Quote
  #11  
Old 01-01-2008, 10:08 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Well, it's making progress, but a little slower because of being busy (*cough* New Year *cough*)..
__________________
Reply With Quote
  #12  
Old 01-01-2008, 10:43 PM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan is on a distinguished road
Post what you have guys, work together!
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #13  
Old 01-02-2008, 12:00 AM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
well got a little more complicated than i thought in the beginning xD
I'm stuck because of the Bug with the param going to 0(see my other thread here for that), but If you want I will post it even if its not fully finished

NPC VotingControlSystem

PHP Code:
enum
  
{
  
MSG_RES_ERROR,   // 0 == false
  
MSG_RES_OK       // 1 == true
  
}

function 
onCreated()
  {
  
//#CONFIG SECTION
  
this.maxpoints 5//Maximum Points per Player
  
this.staff = { "projectigi" };
  
//#END CONFIG SECTION
  
}
  
public function 
applyVPointvIDvTextvPointpAcc )
  {
  if( 
vPoint != || vPoint == ) return( MSG_RES_ERROR );
  if( 
player.account.length() <= ) return( MSG_RES_ERROR );
  if( 
this.(@ "votepoints_" player.account ).size() == || this.(@ "votepoints_" player.account ).length() == )
    {
    
this.(@ "votepoints_" player.account ).add"0" );
    }
  if( ( 
vID != && vID == null ) || vID || vID.length() <= )
    {
    
vID getvIDvText );
    if( 
vID == -) return( MSG_RES_ERROR );
    }  
  
temp.fID = -1;
  
temp.pPoints 0;

  for( 
1this.(@ "votepoints_" player.account ).size(); j++ )
    {
    if( 
this.(@ "votepoints_" player.account )[ ][ ] == vID )
      
temp.fID j;
    
temp.pPoints += ( this.(@ "votepoints_" player.account )[ ][ ] < this.(@ "votepoints_" player.account )[ ][ ] * -this.(@ "votepoints_" player.account )[ ][ ] ) * this.votesvID ][ ];
    }
  
//if( temp.pPoints == this.maxpoints && vPoint > 0 ) return( MSG_RES_ERROR );
  
if( temp.pPoints this.maxpoints )
    {
    
sendtorc"{Vote-Error] Player " player.account " has more than " this.maxpoints " points on votes.(Hacker?)" );
    return( 
MSG_RES_ERROR );
    }
//echo( ( vPoint > 0 ? vPoint : vPoint * -1 ) SPC temp.pPoints );
  
if( temp.pPoints + ( vPoint vPoint vPoint * -) > this.maxpoints && this.votesvID ][ ] + this.votesvID ][ ] >= ) return( MSG_RES_ERROR );
  if( 
vPoint != this.votesvID ][ ] && vPoint != this.votesvID ][ ] * -) return( MSG_RES_ERROR );
  if( 
temp.fID == -this.(@ "votepoints_" player.account ).add( { vIDvPoint } );
  else
    {
    
this.(@ "votepoints_" player.account )[ temp.fID ][ ] += vPoint;
    
this.(@ "votepoints_" player.account )[ ] = temp.pPoints + ( vPoint vPoint * -vPoint );
    }
  
reCalcVotePointsvID );
  return( 
getVoteListpAcc ) );
  }
  
public function 
getVoteListpAcc )
  {
  if( 
pAcc == null || pAcc.length() <= ) return( MSG_RES_ERROR );
  return( { 
this.votesthis.(@ "votepoints_" pAcc ) } );
  }
  
function 
reCalcVotePointsvID )
  {
  
temp.pPointsP 0;
  
temp.pPointsN 0;  
  if( ( 
vID != && vID == null ) || vID || vID.length() <= ) return( MSG_RES_ERROR );
  for( 
temp.agetstringkeys"this.votepoints_" ) )
    {
    if( 
this.(@ "votepoints_" temp.) == null || this.(@ "votepoints_" temp.).length() == || this.(@ "votepoints_" temp.).size() <= ) continue;
    
temp.skipfirst true;
    for( 
temp.bthis.(@ "votepoints_" temp.) )
      {
      if( 
temp.skipfirst == true )
        {
        
temp.skipfirst false;
        continue;
        }
      if( 
temp.b] == vID )
        {
        
temp.(@ "pPoints" @ ( temp.b] > "P" "N" ) ) += temp.b];
        }
      }
    }
  
this.votesvID ][ ] = temp.pPointsP;
  
this.votesvID ][ ] = temp.pPointsN;
  }  
  
public function 
addVotevoteText )
  {
  if( 
player.account in this.staff )
    {
    
this.votes.add( { voteText10} );
    return( 
MSG_RES_OK );  
    }
  return( 
MSG_RES_ERROR );
  }
  
public function 
removeVotevIDvText )
  {
  if( !( 
player.account in this.staff ) ) return( MSG_RES_ERROR );
  if( 
vID == null || vID || vID.length() <= )
    {
    
vID getvIDvText );
    if( 
vID == -) return( MSG_RES_ERROR );
    }
  if( 
this.votesvID ][ ] != vText || ( vText.length() == || vText == null || vText <= ) ) return( MSG_RES_ERROR );
  
this.votes.deletevID );
  return( 
MSG_RES_OK );
  }  
  
function 
getvIDvText )
  {
  if( 
vText == null || vText || vText.length() <= ) return( -);
  
vID = -1;
  for( 
0this.votes.size(); i++ )
    {
    if( 
vText == this.votes][ ] )
      {
      
vID i;
      break;
      }
    }
  if( 
vID == -) return( -);
  return( 
vID );  
  } 
Weapon:

too long for a post...(17k characters, 10k is limit lol)
http://nopaste.info/1e0eb25243.html
__________________
Reply With Quote
  #14  
Old 01-02-2008, 08:49 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Hmm, I was mainly going to do it all in one NPC, but that would be odd, so I need to change my code

I was thinking of some features, dunno if they are needed tho: (This is the config() function)

PHP Code:
function config() {
  
this.categories = { // Add categories here
    
"General",
    
"Level Design",
    
"Errors",
    
"Suggestions",
    
"New Features"
  
};
  
this.vote_mode 1/* 1 will give you an amount of
                           points per voting alternative.
                           
                         2 will give you max amount of
                           points to spend on voting */
                           
  
this.points 3/* mode 1 = amount of points per alternative
                      mode 2 = max amount of points to vote with */
  
  
this.minimum_alternatives 3/* minimum amount of alter-
                                    tives that you need before
                                    mode 1 will be used. Until
                                    then (mode 1) there will be 1 point
                                    per alternative */
                                    
  
this.default_category "Misc"/* When adding an alternative
                                     and the category isn't listed
                                     in this.categories this will
                                     be listed as the category instead */
  
this.canvote false// if the player can vote, if command is disabled it must be turned on with a rc command 
  
clearAlternatives();
  
  
// Add alternatives here: alternative(category, suggestion);
  
alternative("Level Design""Move the osl to an other island");
  
alternative("General""Allow players to buy secret weapons");
  
alternative("New Features""Allow more options with the party system");
  
alternative("General""Release mining");
  
  
temp.array = getAlternatives();
  
triggeraction(this.0.5this.0.5"Client""sync", array);

Only problem is that, by using one npc/db I have to use triggeraction()
And triggeraction() is being annoying from serverside to clientside when it works clientside to serverside
__________________
Reply With Quote
  #15  
Old 01-02-2008, 10:52 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
use triggerserver/triggerclient?
__________________
Deep into the Darkness peering...
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 03:17 PM.


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