VIP

Started by FinchDon, Sep 19, 2015, 11:13 AM

Previous topic - Next topic

FinchDon

VIP
I made this function

function SetVIP( player, amount )
{
      QuerySQL(sqliteDB, "UPDATE Accounts SET VIP='" +  amount + "' WHERE Name='" + player.Name + "'");   
}

function GetVIP( player )
{
   local lvl1 =  GetSQLColumnData( QuerySQL( sqliteDB, "SELECT VIP FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
   if ( lvl1 ) return lvl1;
   else return 0;
}

And This Command

if ( cmd == "buyvip")
{
if ( pstats[ player.ID ].Logged == false ) PrivMessage( player, "You are not logged in");
    else if ( GetCoins( player ) <= 1000 ) PrivMessage( player, "You need to have atleast 1000 BFME Coints for VIP");
else
{
QuerySQL(sqliteDB, "UPDATE Accounts SET VIP= 'true' WHERE Name='" + player.Name + "'");   
SetCoins( player, GetCoins( player ) - 1000 );
PrivMessage( player, "Congratulation You Become New VIP");
Message( " " + player.Name + "has become New VIP of a Server");
}
}

when i type !buyvip  i have everything coins and get logged in it show last PRIVMESSAGE and when i go to database it show True

but when i type !vip

It Show no VIP Online

else if ( ( cmd == "vip" ) || ( cmd == "vip" ) )
{
local plr, b;
for( local i = 0; i < GetMaxPlayers(); i++ )
{
    plr = FindPlayer( i );
if ( ( plr ) && ( GetVIP( plr ) == true ) )
    {
if ( b ) b = b + ", " + plr.Name + " "
else b = plr.Name + " "
    }
}
if ( b ) Message( "**In Game[ VIP Online: [ " + b + " ] ]" );
else Message( "** In Game [ No VIP Online ]." );
}

and also use this

function onPlayerSpawn( player )
{
if ( GetVIP( player ) == true ) player.Health = 0;
}

But when i spawn It is True in db  VIP but It Didn't kill me Why?

For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

FinchDon

For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

#2
Atleast have a common sense
Take a look at your code:-
function GetVIP( player )
{
   local lvl1 =  GetSQLColumnData( QuerySQL( sqliteDB, "SELECT VIP FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
   if ( lvl1 ) return lvl1;
   else return 0;
}

It'll return lvl1
Use something like this:-
function GetVIP( player )
{
   local lvl1 =  GetSQLColumnData( QuerySQL( sqliteDB, "SELECT VIP FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
   if ( lvl1 == true ) return true;
   else return false;
}
oh no

FinchDon

Solved i change true/false to 0/1
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Thijn

I would like to add that this will lag the shit out of your server. I can spam !vip and it will do a query for each online player. Ouch.

FinchDon

try spam @Thijn It will give you a great kick anyway  test it.
It show all players who have VIP Greater than 0
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

MacTavish

Better use array intsead query

I mean
onLogin functions
{
stats[player.ID].VIP = GetSQLColumnData( QuerySQL( sqliteDB, "SELECT VIP FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
}
And cmd
else if ( ( cmd == "vip" ) || ( cmd == "vip" ) )
 {
  local plr, b;
  for( local i = 0; i < GetMaxPlayers(); i++ )
  {
     plr = FindPlayer( i );
  if ( ( plr ) && ( stats[plr.ID].VIP == true ) )
     {
  if ( b ) b = b + ", " + plr.Name + " "
  else b = plr.Name + " "
     }
  }
  if ( b ) Message( "**In Game[ VIP Online: [ " + b + " ] ]" );
  else Message( "** In Game [ No VIP Online ]." );
 }

Since we are just doing query once when they login so this wont have to lag like before @Thijn

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

FinchDon

k i will try thàt @Kusanagi
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

Add that on playerclass
and the rest, think about it.
oh no