This topic was marked solved by its starter, on September 19th, 2015, 01:32 PM
VIP

FinchDon

  • Sr. Member
  • Posts: 252
VIP
« on September 19th, 2015, 12:13 PM »Last edited on September 19th, 2015, 12:17 PM
I made this function

Code: [Select]
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

Code: [Select]
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

Code: [Select]
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

Code: [Select]
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?

Code: [Select]
Re: VIP
« Reply #1, on September 19th, 2015, 12:41 PM »
reply?
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: VIP
« Reply #2, on September 19th, 2015, 01:03 PM »Last edited on September 19th, 2015, 01:05 PM
Atleast have a common sense
Take a look at your code:-
Code: [Select]
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:-
Code: [Select]
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;
}
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

FinchDon

  • Sr. Member
  • Posts: 252
Re: VIP
« Reply #3, on September 19th, 2015, 01:32 PM »
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

  • VC:MP Beta Tester
  • Posts: 1,688
Re: VIP
« Reply #4, on September 19th, 2015, 01:37 PM »
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

  • Sr. Member
  • Posts: 252
Re: VIP
« Reply #5, on September 19th, 2015, 02:03 PM »
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

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 809
Re: VIP
« Reply #6, on September 19th, 2015, 02:13 PM »
Better use array intsead query

I mean
Code: [Select]
onLogin functions
{
stats[player.ID].VIP = GetSQLColumnData( QuerySQL( sqliteDB, "SELECT VIP FROM Accounts WHERE Name='" + player.Name+"'" ), 0 );
}
And cmd
Code: [Select]
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

  • Sr. Member
  • Posts: 252
Re: VIP
« Reply #7, on September 19th, 2015, 02:17 PM »
k i will try thàt @Kusanagi
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: VIP
« Reply #8, on September 19th, 2015, 02:36 PM »
Add that on playerclass
and the rest, think about it.
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN