How to Add Props Sytem

Started by Luckshya, Jun 14, 2015, 10:13 AM

Previous topic - Next topic

Luckshya

I want to knw how to add props system.
Like standing on the buy prop pickup and buying it and selling it?
How to add
 I hv added 1 prop in the db.
and added this in main.nut but still not pickup coming.

Quotefunction onPickupPickedUp( player, pickup )
{   
    pickup.RespawnTime = 2;
   if ( pickup.Model == 407 )
   {
       local q = QuerySQL( db, "SELECT * FROM Props WHERE rowid='" + pickup.ID + "'" );
      if ( q )
      {
      ePrivMessage( "===> " + GetSQLColumnData( q, 0 ) + " <===", player );
      ePrivMessage( "ID:[ " + pickup.ID + " ] Cost:[ $" + GetSQLColumnData( q, 1 ) + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
      ePrivMessage( "Forsale:[ " + CheckForsale( pickup.ID ) + " ]", player );
       }
   }
}
and at tht loc pickup not coming
can u tell me wht to do next.
I hv not done anything more.

Luckshya

can u give me whole function pls bro finchdon how to do send me bro plzzzzz :'(
ihv shown up wht i hv done now send me pic wht i hv to do plzz

Luckshya

Can anyone else send me wht i hv to do next?

hotdogcat

#3
I'll give you some tips,
1)create in the db a table called Props
2)Create proprieties functions(like checkowner, checkforsale, getpropinfo, loadprop etc)
3)If you want to add properties more easily create /addprop command
4)Make when a player touch the pickup a system to tell property info(you can use getpropinfo)




Credits to Bart.

Luckshya

:-\
Can u send me this plz make it for me and i will add
ok?
Tell me wht to add where plzz
Pls dont deny

hotdogcat

What do you mean where to add?

In your script obviously.

You have to make it youself, if you want to get some ideas visit this forum http://vcmp.liberty-unleashed.co.uk/forum/


Credits to Bart.

Honey


Luckshya

This is the error when i added in main.nut

I added this
Quote//Load All Props...
   NewTimer( "LoadProps", 500, 0 );
   NewTimer( "LoadPickups", 700, 0 );


and this is the error

http://i.imgur.com/HJhkLxM.png


Thijn

What do you think that error means? The functions you tell it to call doesn't exist...

So, make them.

Luckshya

Before this i added

in functions

Quotefunction LoadProps()
{
try{

if ( CountProps() != 0 )
{
local q = QuerySQL( db, "SELECT * FROM Props WHERE rowid LIKE '%'" ), pos;
while( GetSQLColumnData( q, 0 ) )
{
local coords = GetSQLColumnData( q, 4 );
local pos = split( coords, " " );
local x = pos[0], y = pos[1], z = pos[2];
CreatePickup( 407, Vector( x.tofloat(), y.tofloat(), z.tofloat() ) );
GetSQLNextRow( q );
}
FreeSQLQuery(q);
}   
   
}
catch(e) print( "function LoadProps() error: " + e );
}

function CountProps()
{
local a = 0, q = QuerySQL( db, "SELECT * FROM Props" );
while ( GetSQLColumnData( q, 0 ) )
{
a ++;
GetSQLNextRow( q );
}
return a; 
FreeSQLQuery( q );
}

//This Function is used to Return "yes" or "No" for the Prop Info like: ** pm >> Forsale:[ No ]...
function CheckForsale( id )
{
local q = QuerySQL( db, "SELECT * FROM Props WHERE rowid='" + id + "'" );
local owner = GetSQLColumnData( q, 2 );
if ( owner == "None" ) return "Yes";
else return "No";
}

//This one is to check if a prop is for sale or not...
function IsPropForSale( id )
{
local q = QuerySQL( db, "SELECT Owner FROM Props WHERE rowid='" + id + "'" );
local owner = GetSQLColumnData( q, 2 );
if ( owner == "None" ) return 1;
else return 0;
}

function IsPropShared( id )
{
local q = QuerySQL( db, "SELECT Owner FROM Props WHERE rowid='" + id + "'" );
local share = GetSQLColumnData( q, 3 );
if ( share == "None" ) return 0;
else return 1;
}

//Some Functions below are just used in /myprops. They aren't used more then 1 time to avoid to many Queries..

function GetPropOwner( id )
{
local get = GetSQLColumnData( QuerySQL( db, "SELECT Owner FROM Props WHERE rowid='" + id + "'" ), 0 );
if ( get ) return get;
else return 0;
}

function GetPropName( id )
{
local get = GetSQLColumnData( QuerySQL( db, "SELECT Name FROM Props WHERE rowid='" + id + "'" ), 0 );
if ( get ) return get;
else return 0;
}

function GetPropShare( id )
{
local get = GetSQLColumnData( QuerySQL( db, "SELECT Shared FROM Props WHERE rowid='" + id + "'" ), 0 );
if ( get ) return get;
else return 0;
}

function GetPropCost( id )
{
local get = GetSQLColumnData( QuerySQL( db, "SELECT Cost FROM Props WHERE rowid='" + id + "'" ), 0 );
if ( get ) return get;
else return 0;
}

function GetPropPos( id )
{
local get = GetSQLColumnData( QuerySQL( db, "SELECT Pos FROM Props WHERE rowid='" + id + "'" ), 0 );
if ( get ) return get;
else return 0;
}

function PropExists( id )
{
if ( id <= CountProps() ) return 1;
else return 0;
}
function IsPropOwnerOrSharer( id, player )
{
local q = QuerySQL( db, "SELECT * FROM Props WHERE rowid='" + id + "'" );
local owner = GetSQLColumnData( q, 2 ), shared = GetSQLColumnData( q, 3 );
if ( ( owner == player.Name ) || ( shared == player.Name ) ) return 1;
else return 0;
   
}


And also added in main.nut

Quotefunction onPickupPickedUp( player, pickup )
{   
    pickup.RespawnTime = 2;
   if ( pickup.Model == 407 )
   {
       local q = QuerySQL( db, "SELECT * FROM Props WHERE rowid='" + pickup.ID + "'" );
      if ( q )
      {
      MessagePlayer( "===> " + GetSQLColumnData( q, 0 ) + " <===", player );
      MessagePlayer( "ID:[ " + pickup.ID + " ] Cost:[ $" + GetSQLColumnData( q, 1 ) + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
      MessagePlayer( "Forsale:[ " + CheckForsale( pickup.ID ) + " ]", player );
       }
   }
}


and when i run this by adding this u see above it runs but when i use /addprop it adds the pickup and also all wht i saved goes to db
but when restart pickup does not come.

and when i added this in main.nut

Quote//Load All Props...
   NewTimer( "LoadProps", 500, 1 );
   NewTimer( "LoadPickups", 700, 1 );


It shows this error

http://i.imgur.com/HJhkLxM.png

Luckshya

Can u tell me is there anything wrong or missing.

Thijn

You probably added the functions in the wrong file, or are calling them before dofile'ing the file you added them in.

Luckshya

#12
Quote from: FinchDon on Jun 14, 2015, 07:02 PMThere is no problem with your function u just add timer at wrong place

Finchdon pls tell me where to add timer
And if u can send me pic i will be vry thankful to u

Luckshya

#13
I added timer in main.nut pls tell me where to add ?
And i will be vry thnkfull to u if u can send me pic.
Finchdon tnx

Luckshya

Hey this is the cmd i used to add props /addprop

else if ( cmd == "addprop" )
{
if ( GetLevel( player ) >= 4 )
{
if ( player.IsSpawned )
{
if ( text )
{
local TextSplit = split( text, " " );

local Name = TextSplit[ 0 ], Cost = TextSplit[ 1 ];

local x = player.Pos.x, y = player.Pos.y, z = player.Pos.z;

QuerySQL( db, "INSERT INTO Properties ( Name, Cost, Owner, Shared, Pos ) values ( '" + Name + "', '" + Cost + "', 'None', 'None', '" + x + " " + y + " " + z + "' )" );

local Pos = Vector( x.tofloat(), y.tofloat(), z.tofloat() );

CreatePickup( 407, Pos );

MessgaePlayer( "New Property - Name: " + Name + ", Cost: " + Cost, player );
}
else MessgaePlayer( "Usage: /c " + cmd + " <prop name> <cost>", player );
}
else MessgaePlayer( "Error - You haven't spawned.", player );
}
else MessgaePlayer( "Error - You need to be at least level 4.", player );
}



Can u chk and tell me is it correct