03.06.2011, 15:54
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?
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);
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;
}
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.
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;
}
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.
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. |
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;
}