Server Crashed getcar

Started by zeko, May 13, 2015, 01:30 PM

Previous topic - Next topic

zeko

im using this cmd when i use the cmd my server got crashed bad

else if ( cmd == "getcar" )



{



    local q = QuerySQL( db, "SELECT * FROM Cars WHERE rowid LIKE '" + text + "'" );



local id = player.ID



if ( !player.IsSpawned ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]You have to be spawned.", player );



else if ( !text )  MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]/" + cmd + " <vehicle ID>", player );



else if ( !IsNum( text ) ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]Vehicle ID must be in number.", player );



else



{



    local veh = FindVehicle( text.tointeger() );



if ( veh.ID > GetVehicleCount() ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]Invalid Vehicle ID.", player );



else if ( !IsOwnerOrSharer( veh, player ) ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]You do not own this Vehicle.", player );



else



{



     MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]Taking vehicle " + GetVehicleNameFromModel( veh.Model ) + " to you.", player );



veh.Pos = Vector( player.Pos.x + 6, player.Pos.y, player.Pos.z - 1 );



                    veh.Angle = player.Angle;



}



}



}


Diego^

Remove veh.Angle = player.Angle;
BRL's Developer.

.

You haven't really specified what crashes your server. Any error message or any information available ?
else if ( cmd == "getcar" )
{
// I believe there's supposed to b some %...% in that query
// Also, shouldn't that text be escaped first?
local q = QuerySQL( db, "SELECT * FROM Cars WHERE rowid LIKE '%" + escapeSQLString(text) + "%'" );
local id = player.ID; // Shouldn't here be a semicolon?

if ( !player.IsSpawned ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]You have to be spawned.", player );
else if ( !text )  MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]/" + cmd + " <vehicle ID>", player );
else if ( !IsNum( text ) ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]Vehicle ID must be in number.", player );
else {
local veh = FindVehicle( text.tointeger() );
// Need to check if the retrieved vehicle is valid first
if ( veh == null ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]Unable to find the specified vehicle.", player );
else if ( veh.ID > GetVehicleCount() ) MessagePlayer( "[#FF0000][ERROR] - [#F7FE2E]Invalid Vehicle ID.", player );
else {
MessagePlayer( "[#40FF00][COMMAND] - [#F7FE2E]Taking vehicle " + GetVehicleNameFromModel( veh.Model ) + " to you.", player );
veh.Pos = Vector( player.Pos.x + 6, player.Pos.y, player.Pos.z - 1 );
veh.Angle = player.Angle;
}
}
}
.