02.11.2010, 18:23
(
Последний раз редактировалось Sascha; 02.11.2010 в 19:25.
)
Hi...
I made a cmd for admins to spawn vehicles...
When I enter /veh bullet 123 123 it returns the message "Server: Unkown Command", AND spawns the bullet....
Why does it show the "Server: Unkown Command"? (I changed the message to "Checkout /cmds dumbass" anyway and it also works if you enter a wrong cmd, so I have no clue why it shows the default message...)
command:
GetVehicleFromName:
Any ideas?
I made a cmd for admins to spawn vehicles...
When I enter /veh bullet 123 123 it returns the message "Server: Unkown Command", AND spawns the bullet....
Why does it show the "Server: Unkown Command"? (I changed the message to "Checkout /cmds dumbass" anyway and it also works if you enter a wrong cmd, so I have no clue why it shows the default message...)
command:
pawn Код:
dcmd_veh(playerid, params[])
{
if(PlayerData[playerid][Level] >= 4){
new tmp[256], idx;
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, GREY, "/v [model] [color1] [color2]");
return 1;
}else{
new model = GetVehicleFromName(tmp);
if(model == -1){
SendClientMessage(playerid, RED, "Invalid Model!");
return 1;
}else{
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, GREY, "/v [model] [color1] [color2]");
return 1;
}else{
new c1 = strval(tmp);
if(!IsNumeric(tmp)){
SendClientMessage(playerid, RED, "Invalid Color!");
return 1;
}else{
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, GREY, "/v [model] [color1] [color2]");
return 1;
}else{
new c2 = strval(tmp);
if(!IsNumeric(tmp)){
SendClientMessage(playerid, RED, "Invalid Color!");
return 1;
}else{
new Float:x, Float:y, Float:z, Float:a, name[MAX_PLAYER_NAME], string[256];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
x += (4 * floatsin(-a, degrees));
y += (4 * floatcos(-a, degrees));
new v = CreateVehicle(model, x, y, z, a, c1, c2, 180);
VehicleData[v][created] = 1;
format(string, sizeof(string), "@%s spawned a %s - destroyable by using \"/destry\" ", name, VehicleTittle[model+400]);
AdminMsg(string);
Log(string);
return 1;
}
}
}
}
}
}
}
return 1;
}
pawn Код:
stock GetVehicleFromName(text[])
{
if(IsNumeric(text)){
new id = strval(text);
if(id < 0 || id > 211){
return -1;
}else{
return id;
}
}
for(new n=0; n<211; n++){
if(strfind(VehicleTittle[n], text, true) != -1){
return n + 400;
}
}
return -1;
}