Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: :P on Sep 17, 2015, 08:13 AM

Title: null
Post by: :P on Sep 17, 2015, 08:13 AM
when i type /car its say cose null ; 0x00000 owner null 0x000 sharer nul 0x0000 why
note: the cmds of kakan

car cmds
else if ( cmd == "car" )
 {
      local plr = GetPlayer( text );
  if ( !text ) MessagePlayer( "[Syntax] - /" + cmd + " <Nick/ID>.", player );
  else{
     if ( !plr ) MessagePlayer( "[Error] - Invalid Nick/ID", player );
  else if ( !plr.IsSpawned ) MessagePlayer( "[Error] - This player hasn't spawned.", player );
  else
  {
   local veh = plr.Vehicle;
   if ( veh )
   {
    local vid = veh.ID, hp = veh.Health.tointeger() /10;
    MessagePlayer( plr + " is driving a " + GetVehicleNameFromModel( veh.Model ) + " (ID: " + vid + ") (Health: " + hp + "%)", player );
    local q = QuerySQL( db, "SELECT * FROM Vehicles WHERE ID='" + veh.ID + "'" );
             MessagePlayer( "Vehicle:[ " + GetVehicleNameFromModel( veh.Model ) + " ] Cost:[ " + GetSQLColumnData( q, 1 ) + " ]", player );
             MessagePlayer( "ID:[ " + veh.ID + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
   }
   else MessagePlayer( plr + " is currently on foot.", player );
  }
  }
 }

function


function onPlayerEnterVehicle( player, vehicle, isPassenger )
{
 Announce( "~b~ ID ~p~" +  vehicle.ID  + ".",player,4);
MessagePlayer("[#1fcecb]Press [#50c878]I[#1fcecb] rapidly to activate boost .",player); 
MessagePlayer("[#FFFFFF]Have 100000?.Type /buycar " + vehicle.ID + " to buy this car if its forsale",player);   
return 1;
}
function onPlayerExitVehicle( player, vehicle )
{
                  Announce( "~b~ ID ~p~" +  vehicle.ID  + ".",player,4);
ePrivMessage("Exit Vehicle ID: " + vehicle.ID + ".",player);
}
(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi58.tinypic.com%2F30ws3tv.png&hash=f9c317422c2dde3040d1dbc7c9dba0740ebf68e0)
Title: Re: null
Post by: MacTavish on Sep 17, 2015, 08:15 AM
Because you havent saved vehicle data in database. Have you created Vehicles table in db? Search EXISTS Vehicles in your .nut files and pass that line here
Title: Re: null
Post by: :P on Sep 17, 2015, 08:18 AM
function VehExists( veh )
{
    if ( veh <= GetVehicleCount() ) return 1;
   else return 0;
}
Title: Re: null
Post by: :P on Sep 17, 2015, 08:29 AM
in database the table added with cars
Title: Re: null
Post by: KAKAN on Sep 17, 2015, 08:30 AM
Wait.. What? My cmds? I have never done a query on a simple car cmd
Better use this one:-
http://forum.vc-mp.org/?topic=1454.0
Title: Re: null
Post by: KAKAN on Sep 17, 2015, 08:31 AM
And yes, how did you announce the text at the bottom of the screen?(left-bottom)
Title: Re: null
Post by: :P on Sep 17, 2015, 08:34 AM
this script cmds doesnt works for me i try
Title: Re: null
Post by: MacTavish on Sep 17, 2015, 08:36 AM
Forget that,

Just do /iamdoing once while in server then wait 5 minutes

Put this cmd
else if(cmd =="iamdoing")
{
MessagePlayer("doing just wait 5 minutes",player);
QuerySQL(db, "CREATE TABLE IF NOT EXISTS Vehicles ( Cost INT, Owner TEXT, Shared TEXT)");
local Max= GetVehicleCount();
for(local i=0; i < Max; i++)
{
QuerySQL( db, "INSERT INTO Vehicles ( Cost, Owner, Shared) VALUES ( '600000', 'Vice-City', 'None')" );
print("Done ID: "+i.tointeger());
}
}
After 5 minutes restart server then try /car
Title: Re: null
Post by: :P on Sep 17, 2015, 08:51 AM
same error
Title: Re: null
Post by: :P on Sep 17, 2015, 08:54 AM
in db   table name is cars and in cmds everywhere vehicles involved is its effect
Title: Re: null
Post by: MacTavish on Sep 17, 2015, 08:57 AM
Yea it effects try changing Vehicles to cars
Title: Re: null
Post by: KAKAN on Sep 17, 2015, 09:03 AM
Quote from: xxkillerxx on Sep 17, 2015, 08:54 AMin db   table name is cars and in cmds everywhere vehicles involved is its effect

LOL!! You should tell this at 1st
Title: Re: null
Post by: :P on Sep 17, 2015, 09:04 AM
solved but its credits goto whose   ;) :D
i want to when i sited in cars i type /car show me its price owner ect dont ask for nick in which car i sit tell me the car information if i am not in car then ask nick
Title: Re: null
Post by: :P on Sep 17, 2015, 09:05 AM
Quote from: xxkillerxx on Sep 17, 2015, 08:29 AMin database the table added with cars
i tell it but you guys did not take attention i tell you 35 mint ago
Title: Re: null
Post by: rObInX on Sep 17, 2015, 09:23 AM
To do what you meant, just remove the part where it asks for name. Is that so hard?
Please "learn" to script.

else if ( cmd == "car" )
 {
   local veh = player.Vehicle;
   if ( veh )
   {
        local vid = veh.ID, hp = veh.Health.tointeger() /10;
        MessagePlayer( plr + " is driving a " + GetVehicleNameFromModel( veh.Model ) + " (ID: " + vid + ") (Health: " + hp + "%)", player );
        local q = QuerySQL( db, "SELECT * FROM Vehicles WHERE ID='" + veh.ID + "'" );
        if ( GetSQLColumnData( q, 1 ) )
        {
         MessagePlayer( "Vehicle:[ " + GetVehicleNameFromModel( veh.Model ) + " ] Cost:[ " + GetSQLColumnData( q, 1 ) + " ]", player );
         MessagePlayer( "ID:[ " + veh.ID + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
        }
     }
 }
Title: Re: null
Post by: :P on Sep 17, 2015, 09:33 AM
if i want to check any one else car with nick will it works
Title: Re: null
Post by: rObInX on Sep 17, 2015, 09:38 AM
Quote from: xxkillerxx on Sep 17, 2015, 09:33 AMif i want to check any one else car with nick will it works

Why can't you try?
I'll fix the errors.

EDIT:

Since I was free, I've coded it.
Dunno if it works or not.
DON'T EXPECT PEOPLE TO CODE FOR YOU EVERY-TIME.

else if ( cmd == "car" )
{
if ( !text )
{
local veh = plr.Vehicle;
if ( veh )
{
local vid = veh.ID, hp = veh.Health.tointeger() /10;
MessagePlayer( plr.Name + " is driving a " + GetVehicleNameFromModel( veh.Model ) + " (ID: " + vid + ") (Health: " + hp + "%)", player );
local q = QuerySQL( db, "SELECT * FROM Vehicles WHERE ID='" + veh.ID + "'" );
if ( GetSQLColumnData( q, 1 ) )
{
MessagePlayer( "Vehicle:[ " + GetVehicleNameFromModel( veh.Model ) + " ] Cost:[ " + GetSQLColumnData( q, 1 ) + " ]", player );
MessagePlayer( "ID:[ " + veh.ID + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
}
}
else MessagePlayer( "You're currently on foot.", player );
}
else
{
local plr = FindPlayer( text );
if ( !plr ) MessagePlayer( "[Error] - Invalid Nick/ID", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[Error] - This player hasn't spawned.", player );
else
{
local veh = plr.Vehicle;
if ( veh )
{
local vid = veh.ID, hp = veh.Health.tointeger() /10;
MessagePlayer( plr.Name + " is driving a " + GetVehicleNameFromModel( veh.Model ) + " (ID: " + vid + ") (Health: " + hp + "%)", player );
local q = QuerySQL( db, "SELECT * FROM Vehicles WHERE ID='" + veh.ID + "'" );
if ( GetSQLColumnData( q, 1 ) )
{
MessagePlayer( "Vehicle:[ " + GetVehicleNameFromModel( veh.Model ) + " ] Cost:[ " + GetSQLColumnData( q, 1 ) + " ]", player );
MessagePlayer( "ID:[ " + veh.ID + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
}
}
else MessagePlayer( plr.Name + " is currently on foot.", player );
}
}
}
Title: Re: null
Post by: :P on Sep 17, 2015, 09:55 AM
kusnangi help me robin give me a cmds in which we not able to check anyone else car he dont know scripting i think i want which palyer in cars show him his car information dont want nick and for others want nick
Title: Re: null
Post by: MacTavish on Sep 17, 2015, 09:59 AM
Try it

else if ( cmd == "car" )
{
 if ( !text )
 {
local veh= player.Vehicle; // robinx made mistake here by typing plr.Vehicle
  if (veh)
  {
   local vid = veh.ID, hp = veh.Health.tointeger() /10;
   MessagePlayer( player.Name + " is driving a " + GetVehicleNameFromModel( veh.Model ) + " (ID: " + vid + ") (Health: " + hp + "%)", player );
   local q = QuerySQL( db, "SELECT * FROM Vehicles WHERE ID='" + veh.ID + "'" );
   if ( GetSQLColumnData( q, 1 ) )
   {
    MessagePlayer( "Vehicle:[ " + GetVehicleNameFromModel( veh.Model ) + " ] Cost:[ " + GetSQLColumnData( q, 1 ) + " ]", player );
    MessagePlayer( "ID:[ " + veh.ID + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
   }
  }
  else MessagePlayer( "You're currently on foot. So do instead /car <nick/id>", player );
 }
 else
 {
  local plr = GetPlayer( text );
  if ( !plr ) MessagePlayer( "[Error] - Invalid Nick/ID", player );
  else if ( !plr.IsSpawned ) MessagePlayer( "[Error] - This player hasn't spawned.", player );
  else
  {
   local veh = plr.Vehicle;
   if ( veh )
   {
    local vid = veh.ID, hp = veh.Health.tointeger() /10;
    MessagePlayer( plr.Name + " is driving a " + GetVehicleNameFromModel( veh.Model ) + " (ID: " + vid + ") (Health: " + hp + "%)", player );
    local q = QuerySQL( db, "SELECT * FROM Vehicles WHERE ID='" + veh.ID + "'" );
    if ( GetSQLColumnData( q, 1 ) )
    {
     MessagePlayer( "Vehicle:[ " + GetVehicleNameFromModel( veh.Model ) + " ] Cost:[ " + GetSQLColumnData( q, 1 ) + " ]", player );
     MessagePlayer( "ID:[ " + veh.ID + " ] Owner:[ " + GetSQLColumnData( q, 2 ) + " ] Share:[ " + GetSQLColumnData( q, 3 ) + " ]", player );
    }
   }
   else MessagePlayer( plr.Name + " is currently on foot.", player );
  }
 }
}

Try now
Title: Re: null
Post by: :P on Sep 17, 2015, 10:11 AM
 if i gave a valid id its says invalid kusnangi
Title: Re: null
Post by: :P on Sep 17, 2015, 10:27 AM
thanx kusnangi and robin i tryed but i cant so i ask understood