[Include] CreateVehicleForPlayer - Use Names to create vehicles, Easily.
#1

CreateVehicleForPlayer V2.1!

*This is my first include, I was a newbie in pawn back then.

You can use this include to add a new vehicle spawning function.

How it works:

#include <pvehicle>
CreateVehicleForPlayer(playerid, vehiclename[], color1, color2, Float:Health);

pawn Код:
CreateVehicleForPlayer(playerid, "NRG", -1,-1, 1000);
//This will create an NRG bike near the player and automatically put him in
//according to the player's virtual world, interior etc.

//Other examples:
CreateVehicleForPlayer(playerid, "520", -1,-1, 1000);
//As you can see here we put an integer but in the format of a string
//But this will tell the code to spawn a vehicle with id 520, which is a Hydra.

CreateVehicleForPlayer(playerid, "900", -1, -1, 1000);
//It will not create a vehicle with model id 900 cause it doesn't exist.
//Instead it will spawn an FCR-900 for you. ;)
You can also use it this way:
pawn Код:
new myvehicle;
myvehicle = CreateVehicleForPlayer(playerid, "NRG", -1, -1, 1000.0);

// so, you can attach stuff / tele it.. or whateva.
So, we can use names & ids both and easily create vehicles for
a certain player without a lot of other codes.


To delete the PLAYER's Vehicle:
pawn Код:
DeletePlayerVehicle(playerid); //This will ONLY DELETE the vehicle spawned by THIS include!
//And If it is server vehicle, it will respawn it.
Lets see this in a working command (ZCMD & sscanf):
pawn Код:
CMD:car(playerid, params[])
{
    new vname[20];
    if(!sscanf(params,"s[20]",vname))
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            CreateVehicleForPlayer(playerid, vname, -1, -1, 1000.0);
        } else SendClientMessage(playerid, COLOR_RED, "You already have a vehicle.");
    } else SendClientMessage(playerid, COLOR_RED, "Usage: /car [vehicle name]");
    return true;
}
If I use /car turi, it will create a turismo for me.
/car 400, it will create landstalker.
/car bullet, it will create bullet.

SIMPLE!

Now, the download?
Here: Pastebin - Version 2.1
MediaFire - Version 2.1


Place "pvehicle.inc" in pawno/include/ folder.. then add #include <pvehicle> to your script.

If you like my work, Help me to help a community: AlertPay E-Mail: morshidul@hotmail.com
AlertPay Link

-Thanks to Toribio for his include, because i learnt few things from there.

--
Reply
#2

Nice and easy to do.
Reply
#3

Will the others see the car?
Reply
#4

What about deleting the vehicle back?
Reply
#5

Quote:
Originally Posted by Markx
Посмотреть сообщение
Will the others see the car?
Yes Ofcourse.

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
What about deleting the vehicle back?
Oki, I will add this in next version.
Reply
#6

Cool
Reply
#7

Very simple and cool
Reply
#8

very usefull thx nice release ^^
Reply
#9

Cool thanks
Reply
#10

how can i get vehicleid?
Reply
#11

from samp wiki use ****** write samp vehicle ids
Reply
#12

Quote:
Originally Posted by yuri29971102
Посмотреть сообщение
how can i get vehicleid?
All Vehicle ID List
Reply
#13

NICE!
many pople need this INC!
Reply
#14

not works
pawn Код:
CMD:car(playerid, params[])
{
    new vname[20];
    if(!sscanf(params,"s[20]",vname))
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            CreateVehicleForPlayer(playerid, vname, -1, -1);
        } else SendClientMessage(playerid, COLOR_RED, "You already have a vehicle.");
    } else SendClientMessage(playerid, COLOR_RED, "Usage: /car [vehicle name]");
    return true;
}
Код:
TA(ary)1ab\gamemodes\tombodos.pwn(2095) : warning 202: number of arguments does not match definition
it just a warning but when itry to start my server it say run time error invalid file or funtion
please help.....
Reply
#15

he forgot a parameter
so it wont work

pawn Код:
CMD:car(playerid, params[])
{
    new vname[20];
    if(!sscanf(params,"s[20]",vname))
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            CreateVehicleForPlayer(playerid, vname, -1, -1,1000.0); // he forgot VehicleHealth
        } else SendClientMessage(playerid, COLOR_RED, "You already have a vehicle.");
    } else SendClientMessage(playerid, COLOR_RED, "Usage: /car [vehicle name]");
    return true;
}
Reply
#16

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
That's not Vehicle ID, but vehicle models.
Reply
#17

Quote:
Originally Posted by Zh3r0
Посмотреть сообщение
That's not Vehicle ID, but vehicle models.
My Bad. Well, I added it now.

Update:

pawn Код:
new myvehicle;
myvehicle = CreateVehicleForPlayer(playerid, "NRG", -1, -1, 1000.0);
//And now we can attach, do stuff to myvehicle.
Reply
#18

Why add the Syntax playerid for the Function, but dont have usefull If-query like: IsValidPlayerVehicle or IsPlayerInHisVehicle? And wtf:
Quote:

//Instead it will spawn an FCR-900 for you.
Why not only return false or something gonna like that.. Scripters Mistake = FCR 900 - mhh I think not good.

But well, nice. (Add Pastebin please too)
Reply
#19

Quote:
Originally Posted by Pablo Borsellino
Посмотреть сообщение
Why add the Syntax playerid for the Function, but dont have usefull If-query like: IsValidPlayerVehicle or IsPlayerInHisVehicle? And wtf:

Why not only return false or something gonna like that.. Scripters Mistake = FCR 900 - mhh I think not good.

But well, nice. (Add Pastebin please too)
Added a pastebin version.

No worries, model id 900 isn't there, So i guess no scripter will use that unless he wants an fcr.
+ I appreciate your suggestions, will add in later versions.
Reply
#20

wOWW! thaNKS!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)