Author Topic: Radio Streams And Database Problem ( Once Again )  (Read 4216 times)

0 Members and 1 Guest are viewing this topic.

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Radio Streams And Database Problem ( Once Again )
« on: September 18, 2014, 07:21:39 pm »
Hello,

I had 2 issues recently.

Issue 1 :

I tried to create custom Radios.I used  CreateRadioStream( 11, "Test", "Test.adf", 1 ); to create my Radio.Although I can tune in the radio in my car but i cannot listen anything in it.I used .adf files because VC uses them as a default so if i need to use a different extension please inform.

Issue 2 :

I was making a Prop System but faced a difficulty at buying the prop.

*Honey Bought Property[ ( Mansion ) ] ID [ 0 ].

The ID and  the Name are fine but the database is saved by the owner name as player.ID.This is my command :

Code: [Select]
else if ( cmd == "buyprop" )
{
local id = player.ID;
        if ( !player.IsSpawned ) MessagePlayer( "[#FF0000][EFE] You haven't spawned yet..", player );
else if ( !text ) MessagePlayer( "[#FF0000][EFE] Error -  /" + cmd + " <ID>", player );
else {
if ( GetRegistered( player ) == 0 ) MessagePlayer( "[#FF0000][EFE] Error - You must be a registered user to use this command", player );
            else if ( status[player.ID].LoggedIn == 0 ) MessagePlayer( "[#FF0000][EFE] Error - You must be logged in to use this command", player );
else if ( !IsNum( text ) ) MessagePlayer( "[#FF0000][EFE] Error - ID must be Numbers", player );
else {
local s = QuerySQL( g_DB, "SELECT * FROM Props" );
local q = QuerySQL( g_DB, "SELECT * FROM Props WHERE ID LIKE '" + text + "'" );
if ( player.Cash < GetSQLColumnData( q, 2 ) ) MessagePlayer( "[#FF0000][EFE] Error - You need $" + GetSQLColumnData( q, 2 ) + " to Buy this!", player );
//if ( GetSQLColumnData( s, 4 )  == "None" )
else
{
if ( s )
{
        QuerySQL( g_DB, "UPDATE Props SET Owner='" + player.Name + "' WHERE rowid LIKE = '" + text + "'" );
Message( "** " + player.Name + " Bought Property:[ " + GetSQLColumnData( s, 1 ) + " ] ID:[ " + text + " ]" );
//Announce( "~h~Property Purchased!", player, 0 );
               // DecreaseCash( player, GetSQLColumnData( q, 2 ).tointeger() );
    local data = GetSQLColumnData( s, 2 );
local cash = status[ player.ID ].Cash;
    local det = cash - data;
local add = cash - data;
    status[ player.ID ].Cash = det;
player.Cash= add;

}
else MessagePlayer( "[#FF0000][EFE] The Prop Not found in the Database!", player );
}
}
}
}


Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: Radio Streams And Database Problem ( Once Again )
« Reply #1 on: September 18, 2014, 08:32:30 pm »
1)

It's called RadioStream because it needs a stream, not a file. So go online and find yourself an url of a radio stream. Google for shoutcast and you should find plenty.

2)

womfg that's a lot of unneeded SQLite. Why on earth don't you save it in a class or table and save it every so often?

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Re: Radio Streams And Database Problem ( Once Again )
« Reply #2 on: September 19, 2014, 12:00:42 pm »
uhh, I know how to save things in classes using arrays but I tried to keep this cmd simple.Most of my script saves things in arrays and stores them in DB once in 2 min.

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Re: Radio Streams And Database Problem ( Once Again )
« Reply #3 on: September 19, 2014, 06:22:04 pm »
Try this
Code: [Select]
else if ( cmd == "buyprops" )
{

if ( player.IsSpawned )
{
if ( text )
{
if ( IsNum( text ) )
{
local q = QuerySQL( g_DB, "SELECT * FROM Props WHERE rowid = '" + text.tointeger() + "'" );

if ( q )
{
if ( player.Cash >= GetSQLColumnData( q, 2 ) )
{

QuerySQL( g_DB, "UPDATE Props SET Owner = '" + player.Name.tolower() + "' WHERE rowid = '" + text.tointeger() + "'" );
Message( "** " + player.Name + " Bought Property:[ " + GetSQLColumnData( q, 1 ) + " ] ID:[ " + text + " ]" );
//Announce( "~h~Property Purchased!", player, 0 );
// DecreaseCash( player, GetSQLColumnData( q, 2 ).tointeger() );

status[ player.ID ].Cash -= GetSQLColumnData( q, 2 );
player.Cash = status[ player.ID ].Cash;



} else MessagePlayer( "[#FF0000][EFE] Error - You need $" + GetSQLColumnData( q, 2 ) + " to Buy this!", player );

} else MessagePlayer( "[#FF0000][EFE] The Prop Not found in the Database!", player );

} else MessagePlayer( "[#FF0000][EFE] Error - ID must be Numbers", player );

} else MessagePlayer( "[#FF0000][EFE] Error -  /" + cmd + " <ID>", player );
} else MessagePlayer( "[#FF0000][EFE] You haven't spawned yet..", player );

}

I modified it due to my laziness i didnt add the register or logedin sys in this.
I tried it with my server and it work.
I have changed the storing of Name in lower case.
Well that should work
« Last Edit: September 20, 2014, 01:39:24 pm by Flockshot »

Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: Radio Streams And Database Problem ( Once Again )
« Reply #4 on: September 20, 2014, 01:31:41 pm »
Try this
Code: [Select]
-
I modified it due to my laziness i didnt add the register or logedin sys in this.
I tried it with my server and it work.
I have changed the storing of Name in lower case.
Well that should work
That will raise an error when the property doesn't exist. You're checking the cash before checking the query itself.
Also, why do you need 5 lines of code to decrease someone's cash?
You can do it in 2:
Code: [Select]
status[ player.ID ].Cash -= GetSQLColumnData( q, 2 );
player.Cash = status[ player.ID ].Cash;

Offline Flockshot

  • Street Thug
  • *
  • Posts: 29
    • View Profile
Re: Radio Streams And Database Problem ( Once Again )
« Reply #5 on: September 20, 2014, 01:41:11 pm »
That will raise an error when the property doesn't exist. You're checking the cash before checking the query itself.

Oh, sorry i have updated it now
and for
Also, why do you need 5 lines of code to decrease someone's cash?
You can do it in 2:
Code: [Select]
status[ player.ID ].Cash -= GetSQLColumnData( q, 2 );
player.Cash = status[ player.ID ].Cash;
I didnt changed that i just modified some of the lines.
Well but changed it to urs