Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ScriptLoad()
- {
- QuerySQL( db, "CREATE TABLE IF NOT EXISTS Properties ( Name TEXT, Pos TEXT, Price NUMERIC, Owner TEXT, Share TEXT )" );
- LoadProps();
- PropName <- [ "name" ];
- PropPrice <- [ "price" ];
- PropOwner <- [ "owner" ];
- PropShare <- [ "share" ];
- }
- function onPlayerCommand( player, cmd, text )
- {
- if ( cmd == "addprop" )
- {
- if ( !text ) PrivMessage( player, "/" + cmd + " <name> <price>" );
- else
- {
- local name = GetTok( text, " ", 1 ), price = GetTok( text, " ", 2 );
- if ( !price ) PrivMessage( player, "Adicione um valor." );
- CreatePickup( 407, Vector( player.Pos.x, player.Pos.y, player.Pos.z ) );
- QuerySQL( db, "INSERT INTO Properties ( Name, Pos, Price, Owner, Share ) VALUES ( '" + name + "', '" + player.Pos.x + "' '" + player.Pos.y + "' '" + player.Pos.z + "', '" + price + "', 'Ninguem', 'Ninguem' )" );
- }
- }
- }
- function LoadProps()
- {
- local q = QuerySQL( db, "SELECT * FROM Properties" ), a = 0;
- while ( GetSQLColumnData( q, 0 ) )
- {
- local name = GetSQLColumnData( q, 0 ),
- pos = split( GetSQLColumnData( q, 1 ), " " ),
- price = GetSQLColumnData( q, 2 ),
- owner = GetSQLColumnData( q, 3 ),
- share = GetSQLColumnData( q, 4 ),
- x = pos[0],
- y = pos[1],
- z = pos[2];
- PropName.push( name );
- PropPrice.push( price );
- PropOwner.push( owner );
- PropShare.push( share );
- CreatePickup( 407, x.tofloat(), y.tofloat(), z.tofloat() );
- GetSQLNextRow( q );
- a ++;
- }
- FreeSQLQuery( q );
- }
- funtion onPickupPickedUp( player, pickup )
- {
- if ( pickup.Model == 407 ) MessagePlayer( PropName[pickup.ID] + ", Valor " + PropPrice[pickup.ID] + " - Dono: " + PropOwner[pickup.ID] + ", Share: " + PropShare[pickup.ID] );
- }
- 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();
- }
Advertisement
Add Comment
Please, Sign In to add comment