Heal, Armour With Pickup { Money , Time } { Database }

Started by Mahmoud Tornado, Mar 23, 2018, 08:08 PM

Previous topic - Next topic

Mahmoud Tornado

As, i will leave VC-MP for 2 months.
I decided to make something here before.
When some friend asked me to make that i made it, Enjoy!

onScriptLoad() /// Loading Databases
pp <- ConnectSQL("Pickup.sqlite");
::QuerySQL( pp, "CREATE TABLE IF NOT EXISTS PickUpHeal ( PX FLOAT, PY FLOAT, PZ FLOAT )" );
::QuerySQL( pp, "CREATE TABLE IF NOT EXISTS PickUpArmour ( PX FLOAT, PY FLOAT, PZ FLOAT )" );
LoadPickUpHeal();
LoadPickUpArmour();

onScriptUnload()
DisconnectSQL( pp );

onPlayerCommand( player, cmd, text ) //Commands /addhealpickup /addarmourpickup
if ( cmd == "addhealpickup" )
 {
    CreatePickup( 366, Vector( player.Pos.x.tofloat(), player.Pos.y.tofloat(), player.Pos.z.tofloat() ) );
    QuerySQL( pp, "INSERT INTO PickUpHeal ( PX, PY, PZ ) VALUES ( '" + player.Pos.x.tofloat() + "', '" + player.Pos.y.tofloat() + "', '" + player.Pos.z.tofloat() + "' )" );
    Message(player.Name+": [#FFFFFF]PickUp Saved In Database.");
 }
else if ( cmd == "addarmourpickup" )
 {
    CreatePickup( 368, Vector( player.Pos.x.tofloat(), player.Pos.y.tofloat(), player.Pos.z.tofloat() ) );
    QuerySQL( pp, "INSERT INTO PickUpArmour ( PX, PY, PZ ) VALUES ( '" + player.Pos.x.tofloat() + "', '" + player.Pos.y.tofloat() + "', '" + player.Pos.z.tofloat() + "' )" );
    Message(player.Name+": [#FFFFFF]PickUp Saved In Database.");
 }

Load Pickup Functions /// To load the pickup when the server open
function LoadPickUpHeal()
{
 local q = QuerySQL( pp, "SELECT * FROM PickUpHeal" ), i = 0;
 while( GetSQLColumnData( q, 0 ) )
 {
  local
   PX= GetSQLColumnData( q, 0 ),
   PY = GetSQLColumnData( q, 1 ),
   PZ = GetSQLColumnData( q, 2 );
  CreatePickup( 366, Vector( PX.tofloat(), PY.tofloat(), PZ.tofloat() ) );
  GetSQLNextRow( q );
  i++;
 }
 print( "Heal PickUps loaded - " + i );
}

function LoadPickUpArmour()
{
 local q = QuerySQL( pp, "SELECT * FROM PickUpArmour" ), i = 0;
 while( GetSQLColumnData( q, 0 ) )
 {
  local
   PX= GetSQLColumnData( q, 0 ),
   PY = GetSQLColumnData( q, 1 ),
   PZ = GetSQLColumnData( q, 2 );
  CreatePickup( 368, Vector( PX.tofloat(), PY.tofloat(), PZ.tofloat() ) );
  GetSQLNextRow( q );
  i++;
 }
 print( "Armour PickUps loaded - " + i );
}

Pickup Function //Check Money And PlayerHp ----Then----> Timer.
function onPickupPickedUp( player, pickup )
{
if( pickup.Model == 366 )
{
if ( player.Health == 100 ) MessagePlayer( "[#00de00]Command: [#fbf3f3]Error - You don't need to be healed.", player );
else if ( player.Cash < 3000 ) MessagePlayer( "[#00de00]Command: [#fbf3f3]You Need 3k To Heal.", player );
else {
NewTimer( "heal", 3000, 1, player.ID );
Announce( "Healing...", player , 0 );
player.IsFrozen = true;
player.Cash -= 3000;
}
}
if( pickup.Model == 368 )
{
if ( player.Armour == 100 ) MessagePlayer( "[#00de00]Command: [#fbf3f3]Error - You don't need armour.", player );
else if ( player.Cash < 5000 ) MessagePlayer( "[#00de00]Command: [#fbf3f3]You Need 5k To Get Armour.", player );
else {
NewTimer( "armour", 3000, 1, player.ID );
Announce( "Getting Armour...", player , 0 );
player.IsFrozen = true;
player.Cash -= 5000;
}
}
}

After Timer
function heal(p)
{
local player = FindPlayer(p);
if (player) {
player.IsFrozen = false;
player.Health = 100;
MessagePlayer( "[#00de00]Information: [#fbf3f3]You Have Been Healed.", player );
}
}

function armour(p)
{
local player = FindPlayer(p);
if (player) {
player.IsFrozen = false;
player.Armour = 100;
MessagePlayer( "[#00de00]Information: [#fbf3f3]You Have Been Armoured.", player );
}
}

Getplayer , GetTok And NumTok Function.

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
  tokenized = split(string, separator),
  text = "";

if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}
function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return false;
        }
    else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return false;
        }
    }
    else return false;
}

Mohamed Boubekri

| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].


=RK=MarineForce

NICEEEEEEEEEEEEEEEEE

Bro u can make all admin commmands and system with level?

and blast bomb?

Mahmoud Tornado

Quote from: =RK=MarineForce on Mar 24, 2018, 09:03 AMNICEEEEEEEEEEEEEEEEE

Bro u can make all admin commmands and system with level?

and blast bomb?
What is that? ( blast bomb )

Mohamed Boubekri

Quote from: =RK=MarineForce on Mar 24, 2018, 09:03 AMNICEEEEEEEEEEEEEEEEE

Bro u can make all admin commmands and system with level?

and blast bomb?
Thi's Isn't Level System, is Armour & Heal Pickup System.
you can find level system in My Account System
P.S:- Don't Post OFF Topic Here.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

=RK=MarineForce

PROBLEM in  LoadPickUpHeal();
 LoadPickUpArmour();

this

Mahmoud Tornado

Quote from: =RK=MarineForce on Apr 21, 2018, 03:15 PMPROBLEM in  LoadPickUpHeal();
 LoadPickUpArmour();

this
can you give pic for the problem from server log ?

Mohamed Boubekri

Quote from: Mahmoud Tornado on Apr 21, 2018, 04:25 PM
Quote from: =RK=MarineForce on Apr 21, 2018, 03:15 PMPROBLEM in  LoadPickUpHeal();
 LoadPickUpArmour();

this
can you give pic for the problem from server log ?
Here Are no problem, i think @=RK=MarineForce Didn't Add it correctly on he own server.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

=RK=MarineForce


=RK=MarineForce