[Include] SendVehicleToPlayer.inc
#1

SendVehicleToPlayer!
I made a simple include to Send A given vehicleid to a given playerid. It also comes with a neat little SetVehiclePosEx function which is used in the SendVehicleToPlayer stock.

Version 2:
Version 2 goes back to this include, and basically changes it up, - fixes some minor things, and also implements a "putin" feature. Basically, it can be used to put the player in the vehicle(vehid). How-ever it's still backwards compatible since it's an optional param.

This is how you can use it:

1. Put the included .inc file in your pawno - includes folder. Then advance to the next step.
2. At the top of your script, add the include by using "#include <SendVehicleToPlayer>.
3. Where you want to send the vehicle to the playerid use "SendVehicleToPlayer(vehicleid, playerid);".

An example filter-script is provided in the "Solidfiles" download(Version 2 only) Additionally, the code for this can be found below or via pastebin by clicking [URL="http://pastebin.com/bWtP1Sn4"]here");
return 1;
}

Код:
#include a_samp
#include zcmd
#include sscanf2
#include SendVehicleToPlayer2
 
CMD:sendvehtoid(playerid, params[])
{
new giveplayerid, vehid, putin, string[128];
if (sscanf(params, "ud", giveplayerid, vehid, putin)) return SendClientMessage(playerid, -1, "USAGE: /sendvehtoid [playerid] [vehid] [putin(0 - no, 1 - yes)");
if(vehid == INVALID_VEHICLE_ID) return SendClientMessage(playerid, -1, "Invalid vehicleID.");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, -1, "Invalid Player Specified.");
if(putin == 1) return SendVehicleToPlayer(vehid, playerid, 1);
if(putin == 0) return SendVehicleToPlayer(vehid, playerid);
format(string, sizeof(string), "You have sent Vehicle ID %d to PlayerID %d.");
return 1;
}
This is my first include so please only constructive critism. But if you think it was good, you can leave a positive comment!

Links/Downloads:
Pastebin - Click Here.
Solidfiles - Click Here.
NOTE: This is an .inc file, and if you use pastebin you must save it as one.

NOTE: The Solidfiles version ONLY comes with the testing filter-script. The name of the testing filter-script is "testfs_2". This can be accessed from the "filterscripts" folder.
Pastebin(v2) - Click Here
Solidfiles(v2) - Click Here

If you find any bugs, or find a better way I could've coded this then just say so! If you like what you see share the love and leave a nice comment.

- Abagail
Reply
#2

pawn Код:
CMD:BringCar(playerid, params[])
{
    new vehid;
    if(sscanf(params, "i", vehid)) return SendClientMessage(playerid, -1, "USAGE : /bringcar [Vehicle Id]");
    for(new i = 0, k = MAX_VEHICLES; i < k; i++)
    {
        if( i == vehid)
        {
             new Float:x, Float:y, Float:z;
             GetPlayerPos(playerid, x, y, z);
             SetVehiclePos(vehid, x + 5, y + 5, z);
             PutPlayerInVehicle(playerid, vehid);
        }
        else return SendClientMessage(playerid, -1, "ERROR: Invalid Vehicle ID");
    }
    return 1;
}
this code is changed into an include, havent tested it thou it might be useful.
Reply
#3

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
pawn Код:
CMD:BringCar(playerid, params[])
{
    new vehid;
    if(sscanf(params, "i", vehid)) return SendClientMessage(playerid, -1, "USAGE : /bringcar [Vehicle Id]");
    for(new i = 0, k = MAX_VEHICLES; i < k; i++)
    {
        if( i == vehid)
        {
             new Float:x, Float:y, Float:z;
             GetPlayerPos(playerid, x, y, z);
             SetVehiclePos(vehid, x + 5, y + 5, z);
             PutPlayerInVehicle(playerid, vehid);
        }
        else return SendClientMessage(playerid, -1, "ERROR: Invalid Vehicle ID");
    }
    return 1;
}
this code is changed into an include, havent tested it thou it might be useful.
Purpose of this thread is not to convert OP's code to a single untested command (just so you know, posting untested code is against rules). You should rather comment like 'nice job' whatsoever or dont post at all

--

OT:

Good werk mate
Reply
#4

There are few problems with the code:

pawn Код:
stock SetVehiclePosEx(id, x, y, z, vw, int)
x, y, z parameters must have Float tag.
pawn Код:
stock SetVehiclePosEx(id, Float: x, Float: y, Float: z, vw, int)
In SetVehiclePosEx:
pawn Код:
SetPlayerVirtualWorld(playerid, vw);
Assuming you wanted to set the vehicle's vw but you wrote the above by accident. It should be:
pawn Код:
SetVehicleVirtualWorld(id, vw);
You forgot to add the semicolon (;) at the end of these:
pawn Код:
SetVehiclePos(id, x, y, z)
pawn Код:
SetVehiclePosEx(vehid, x, y, z, vw, int)
Atleast, you could try compiling it first before posting it (I read it from pastebin - I don't know if it's the same for the other link).

Also one suggestion. Instead of declaring and storing to two (kind of pointless) variables that are used only once:
pawn Код:
new vw = GetPlayerVirtualWorld(playerid);
new int = GetPlayerInterior(playerid);
SetVehiclePosEx(vehid, x, y, z, vw, int);
You could do that directly:
pawn Код:
SetVehiclePosEx(vehid, x, y, z, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid));
Reply
#5

Thanks for the feed-back. Changing the links to the fixed version.
Reply
#6

Fixed.
Reply
#7

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Fixed.
Why the hell you released an untested include? Which wasn't EVEN compiled with any script, wow.
Reply
#8

As I said, this was my first include.
Reply
#9

Quote:
Originally Posted by fiki574
Посмотреть сообщение
Purpose of this thread is not to convert OP's code to a single untested command (just so you know, posting untested code is against rules). You should rather comment like 'nice job' whatsoever or dont post at all

--

OT:

Good werk mate
I meant that this code does the same work of this include, but i havent tested His include. but that include might be useful.
Reply
#10

Updated.

Change Log:
Version 2;
- Fixed some code
- Added a "put-in" feature.
- Added an example/test filter-script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)