Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Spidey on Aug 28, 2015, 10:54 AM

Title: hey i want something
Post by: Spidey on Aug 28, 2015, 10:54 AM
i want car command can you plzz post here
Title: Re: hey i want something
Post by: Spidey on Aug 28, 2015, 10:57 AM
and want tell you all something seby our friend is gone
Title: Re: hey i want something
Post by: KAKAN on Aug 28, 2015, 11:39 AM
Where did seby go?
Title: Re: hey i want something
Post by: Xmair on Aug 28, 2015, 01:34 PM
He left.
On topic :- Happy scripting.
Use this  code.  (http://forum.vc-mp.org/?topic=1362.msg9258#msg9258)
Title: Re: hey i want something
Post by: KAKAN on Aug 28, 2015, 01:41 PM
Wrong, where are the RGB in....
Title: Re: hey i want something
Post by: Spidey on Aug 28, 2015, 01:56 PM
i dont know saw it in his signature
Title: Re: hey i want something
Post by: Spidey on Aug 28, 2015, 01:57 PM
it is wrong kakan can you plzzz post real snipet here
Title: Re: hey i want something
Post by: SAzEe21 on Aug 28, 2015, 02:02 PM
Use this one.... Hope, it will work fine...
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 );
}
}
}
Title: Re: hey i want something
Post by: FinchDon on Aug 28, 2015, 02:06 PM
Will not work if he don't have queries Easy One

Use GetVehicleNameFromModel( vehicle )
Title: Re: hey i want something
Post by: KAKAN on Aug 28, 2015, 02:31 PM
Here is a simple car cmd:-
else if ( cmd == "car" )
{
if(!text)MessagePlayer("[Syntax]: /" + cmd + " <player ID/Name>.",player );
else
{
local plr = GetPlayer(text)
if(!plr) MessagePlayer("Error: Unknown Player.",player);
else if(!plr.IsSpawned)MessagePlayer("Error: The requested player has not spawned yet.",player);
else if(!plr.Vehicle)MessagePlayer(">> " + plr.Name + " is currently on foot.",player);
else
{
MessagePlayer(">> " + plr.Name + " is driving a " + plr.Vehicle.Model + "." );
}
}
}

Here is the GetPlayer function(add this if u don't have it)
function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
        else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}
Title: Re: hey i want something
Post by: Xmair on Aug 29, 2015, 04:32 AM
Quote from: KAKAN on Aug 28, 2015, 02:31 PMHere is a simple car cmd:-
else if ( cmd == "car" )
{
if(!text)MessagePlayer("[Syntax]: /" + cmd + " <player ID/Name>.",player );
else
{
local plr = FindPlayer(text)
if(!plr) MessagePlayer("Error: Unknown Player.",player);
else if(!plr.IsSpawned)MessagePlayer("Error: The requested player has not spawned yet.",player);
else if(!plr.Vehicle)MessagePlayer(">> " + plr.Name + " is currently on foot.",player);
else
{
MessagePlayer(">> " + plr.Name + " is driving a " + plr.Vehicle.Model + "." );
}
}
}

Here is the GetPlayer function(add this if u don't have it)
function GetPlayer( plr )
{
    if ( plr )
    {
        if ( IsNum( plr ) )
        {
            plr = FindPlayer( plr.tointeger() );
            if ( plr ) return plr;
            else return null;
        }
        else
        {     
            plr = FindPlayer( plr );
            if ( plr ) return plr;
            else return null;
        }
    }
    else return null;
}
@KAKAN This code needs another function, Better use my code.
else if ( cmd == "car" )
{     
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID>.", player ); /*Checks if the player has wrote nothing just /car.*/
else{ /*If the check of text is passed than we will go here.*/
local plr = FindPlayer( text ); /*Finds the player.*/
    if ( !plr ) MessagePlayer( "Error: Invalid player.", player ); /*Checks if the player is online.*/
else if ( !plr.IsSpawned ) MessagePlayer( "Error: This player hasn't spawned.", player ); /* Checks if the player is spawned.*/
else /*If it passed more checks, This will come.*/
{
local veh = plr.Vehicle; /*This just smaller plr.Vehicle to veh.*/
if ( veh ) /*Checks if the player is in a vehicle.*/
{
local vid = veh.ID, hp = veh.Health.tointeger() / 10; /*This will divide the vehicle's hp to 10% because the vehicle's hp is around 1000 when it's 100%.*/
MessagePlayer( plr.Name + " is driving a " + GetVehicleNameFromModel(veh.Model) + " (ID: " + vid + ") (Health: " + hp + "%)", player ); /*Finally sends a message about his car, ID and the vehicle's HP.*/
}
else MessagePlayer( plr + " is currently on foot.", player ); /*If not in a vehicle this will show up.*/
}
}
}
This code will even make him learn something.
Title: Re: hey i want something
Post by: KAKAN on Aug 29, 2015, 05:11 AM
@Xmair What else function does it needs?
Title: Re: hey i want something
Post by: Xmair on Aug 29, 2015, 06:02 AM
@KAKAN I said that your code needs a function which is getplayer, use my command, it won't need any function.
Title: Re: hey i want something
Post by: KAKAN on Aug 29, 2015, 07:21 AM
@Xmair I have provided the getplayer function, can't u see it?
Title: Re: hey i want something
Post by: Xmair on Aug 29, 2015, 08:57 AM
I can see it, I have eyes. You can't understand what I want to say. My function will not need GetPlayer and your will need it. Anyway it's just a small thing, Stop quarelling.
Title: Re: hey i want something
Post by: Thijn on Aug 29, 2015, 10:57 AM
I might be blind, but I definitely see a GetPlayer function in your command as well @Xmair
Title: Re: hey i want something
Post by: Xmair on Aug 29, 2015, 11:03 AM
Quote from: Thijn on Aug 29, 2015, 10:57 AMI might be blind, but I definitely see a GetPlayer function in your command as well @Xmair
Oh, Thanks for notifying me, I actually changed it now, Before I changed GetPlayer to FindPlayer in KAKAN's post by quoting it.