Spawning Vehicle - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spawning Vehicle (
/showthread.php?tid=187400)
Spawning Vehicle Command -
Sascha - 02.11.2010
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:
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;
}
GetVehicleFromName:
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;
}
Any ideas?
Re: Spawning Vehicle -
Sascha - 02.11.2010
hm... noone?
Re: Spawning Vehicle -
HrvojeCro - 02.11.2010
return -1; ? but i think thats correct(half-beginner)
maybe remove Server:Unknown command
https://sampforum.blast.hk/showthread.php?tid=165652
Re: Spawning Vehicle -
Mike_Peterson - 02.11.2010
use sscanf with 2 extra variables...
color1,color2 its easy it assigns a value to the variables and it does strlen ..