Is it Possible to set Vehicle price from cmds If yes then how
Yes, make a cmd and update the Price using a Query or an array.
Ex:-
QuerySQL(db,"UPDATE Vehicles SET Price='" + text + "' WHERE Vehicle ='" + player.Vehicle + "'" )
this is but not works cost does not exists i try with price but dont work else if ( cmd == "setcarprice" )
{
if ( IsNoob( player, cmd ) ) return 0;
else if ( !text ) MessagePlayer("Error, [Syntax] setcarprice <car id> <newprice>", player );
{
local id = GetTok( text, " ", 1 ), newcost = GetTok ( text, " ", 2);
if ( !IsNum( id ) ) MessagePlayer("Error, [Syntax] invalid car id", player );
else
{
if ( !IsNum( newcost ) ) MessagePlayer("Error, [Syntax] the number must be in numbers", player );
else
{
id = id.tointeger();
newcost = newcost.tointeger();
local setnewcost = format( "UPDATE cars SET Price=%i WHERE carID=" + id, newcost );
if ( carcost( id ) == 0 )
{
::QuerySQL( DB, "REPLACE INTO cars (carID) VALUES (" + id + ")" );
}
EMessage( "** Price Changed - car ID: " + id + " - Name: " + Findcar( id ) + " - New cost: $" + Bytes( newcost ) );
QuerySQL( DB, setnewcost );
}
}
}
}
See the table in your database file.
in the table is cost
WTH is this?
if ( carcost( id ) == 0 )
Post an screenshot of your cars table where is your car cost
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi60.tinypic.com%2F15d26va.png&hash=5eeaecb0cd8b7eb27394740847a63c8505a7badd)
AND PLEASE FIX MY CMDS SOON
Here it is
else if ( cmd == "setcarprice" )
{
try {
if ( IsNoob( player, cmd ) ) return 0;
else if ( !text ) MessagePlayer("Syntax - /setcarprice <Vehicle ID> <Cost>", player );
else
{
local id = GetTok( text, " ", 1 ), newprice = GetTok( text, " ", 2 );
if ( !IsNum( id ) ) MessagePlayer("Error - Invalid vehicle ID.", player );
else
{
if ( !IsNum( newprice ) ) MessagePlayer("Error - The price should be in number.", player );
else
{
id = id.tointeger();
newprice = newprice.tointeger();
local setnewprice = format( "UPDATE Cars SET Cost=%i WHERE ID=" + id, newprice );
MessagePlayer("Done -You have changed the price of vehicle Id ( " + id + " ) New price: $" + newprice + "", player );
QuerySQL( db, setnewprice );
}
}
}
}
catch(e) print( "Setcarprice " + e );
}
ENJOY
which cmds i post how is its good my first time try to make
And thanx For cmds