View Single Post
  #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