Cars Command!
#1

Hi all.I want to make a car commadn when i type for example: /car turismo 166 color and when i type it to spawn a turimo with the colour 166.How to that?
Reply
#2

pawn Код:
dcmd_car(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 3)
    {
        new Index;
        new tmp[256];  tmp  = strtok(params,Index);
        new tmp2[256]; tmp2 = strtok(params,Index);
        new tmp3[256]; tmp3 = strtok(params,Index);
        if(!strlen(tmp)) return
        SendClientMessage(playerid, LIGHTBLUE2, "Usage: /car [ModelID/Name] [Colour1] [Colour2]") &&
        SendClientMessage(playerid, orange, "Function: Will create a Car with specified Colours");
        new car;
        new string[128];
        new colour1, colour2;
        if(!IsNumeric(tmp))
        car = GetVehicleModelIDFromName(tmp);
        else car = strval(tmp);
        if(car < 400 || car > 611) return  SendClientMessage(playerid, red, "ERROR: Invalid Vehicle Model ID!");
        if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
        if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
       
        if(AccInfo[playerid][pCar] != -1 && !IsPlayerAdmin(playerid))
        EraseVeh(AccInfo[playerid][pCar]);
        new LVehicleID;
        new Float:X,Float:Y,Float:Z;
        new Float:Angle,int1;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid,Angle);
        int1 = GetPlayerInterior(playerid);
        LVehicleID = CreateVehicle(car, X+3,Y,Z, Angle, colour1, colour2, -1);
        LinkVehicleToInterior(LVehicleID,int1);
        AccInfo[playerid][pCar] = LVehicleID;
        SendCommandToAdmins(playerid,"Car");
        format(string, sizeof(string), "%s Spawned a \"%s\" (Model:%d) Colours (%d, %d), Pos: X:%0.2f, Y:%0.2f, Z:%0.2f", pName(playerid), VehicleNames[car-400], car, colour1, colour2, X, Y, Z);
        SaveIn("CarSpawns",string);
        format(string, sizeof(string), "|- You have Spawned a \"%s\" (Model: %d) with Colours: %d,%d -|", VehicleNames[car-400], car, colour1, colour2);
        return SendClientMessage(playerid,LIGHTBLUE, string);
    }
    else return ErrorMessages(playerid, 6);
Reply
#3

But i dont wnat to work with dcmd
Reply
#4

please help
Reply
#5

Then learn to use it. People should refrain from using outdated and deprecated methods.
Reply
#6

ahhhhhhhhh its to simple D_CMD man wahts a dificult in dcmd
Reply
#7

can someone tell me how to make the command origninal not dcmd!!l
Reply
#8

http://forum.sa-mp.com/forumdisplay.php?f=70

I think there's a tutorial on making your own car system in that forum. Take a look!
Reply
#9

I will show a Simple Example Build from it

pawn Код:
if(strcmp(cmd, "/car", true)==0)
    {
        new tmp2[256], tmp3[256];
        tmp = strtok(cmdtext, idx);
        tmp2 = strtok(cmdtext, idx);
        tmp3 = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_xWHITE, ""xWHITE"Usage: "xGREEN"/car "xWHITE"[VehicleID] "xWHITE"[Color]");
        if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_xWHITE, ""xWHITE"Usage: "xGREEN"/car "xGREEN"[VehicleID] "xWHITE"[Color]");
        new vehid = strval(tmp2);
        new vehcolor = strval(tmp3);
        new Float:x,Float:y,Float:z,Float:a;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid, a);
        CreateVehicle(vehid, x,y,z,a, vehcolor, vehcolor, 60);
        }
        return 1;
    }
Reply
#10

IT gives me those errors

Код:
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(515) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(518) : error 017: undefined symbol "tmp"
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(518) : error 017: undefined symbol "COLOR_xWHITE"
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(518) : error 017: undefined symbol "xWHITE"
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(518) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#11

Try this but i did say Example xd
pawn Код:
if(strcmp(cmd, "/car", true)==0)
    {
        new tmp[256],tmp2[256], tmp3[256];
        tmp = strtok(cmdtext, idx);
        tmp2 = strtok(cmdtext, idx);
        tmp3 = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFAA, "Usage: /car [VehicleID] [Color]");
        if(!strlen(tmp2)) return SendClientMessage(playerid, 0xFFFFFFAA, "Usage: /car  [VehicleID] [Color]");
        new vehid = strval(tmp2);
        new vehcolor = strval(tmp3);
        new Float:x,Float:y,Float:z,Float:a;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid, a);
        CreateVehicle(vehid, x,y,z,a, vehcolor, vehcolor, 60);
        return 1;
    }
Reply
#12

I have three errors
Код:
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(522) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(522) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(522) : warning 219: local variable "z" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Reply
#13

Quote:
Originally Posted by IvancheBG
Посмотреть сообщение
I have three errors
Код:
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(522) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(522) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Documents and Settings\user\Desktop\server samp\gamemodes\Stunt.pwn(522) : warning 219: local variable "z" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
You have allredy define these variables just change them
EDIT: done it for you
pawn Код:
if(strcmp(cmd, "/car", true)==0)
    {
        new tmp[256],tmp2[256], tmp3[256];
        tmp = strtok(cmdtext, idx);
        tmp2 = strtok(cmdtext, idx);
        tmp3 = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFFAA, "Usage: /car [VehicleID] [Color]");
        if(!strlen(tmp2)) return SendClientMessage(playerid, 0xFFFFFFAA, "Usage: /car  [VehicleID] [Color]");
        new vehid = strval(tmp2);
        new vehcolor = strval(tmp3);
        new Float:Px,Float:Py,Float:Pz,Float:Pa;
        GetPlayerPos(playerid,Px,Py,Pz);
        GetPlayerFacingAngle(playerid, Pa);
        CreateVehicle(vehid, Px,Py,Pz,Pa, vehcolor, vehcolor, 60);
        return 1;
    }
Reply
#14

I have a problem i use ladmin4 adn in this admin script there's the same command and it says you need to be level 3 to uuse this command
Reply
#15

You must have a command that already uses that command i mean one for admins to spawn a car and one for player which both are /car change it to /v and try again
Reply
#16

ok i will try
Reply
#17

it dousnt wokr when i type /v turismo and a colour it shows in the chat Usage:/v [vehicleID] [Colour] and nothing just this
Reply
#18

Quote:
Originally Posted by IvancheBG
Посмотреть сообщение
it dousnt wokr when i type /v turismo and a colour it shows in the chat Usage:/v [vehicleID] [Colour] and nothing just this
You dont type the vehicle name you type the ID
Reply
#19

With the id I tried to but nothing itype 451 and nothing
Reply
#20

How to make it to type names not id's!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)