new carroadmin[MAX_PLAYERS];
CMD:cv(playerid, params[]) { new id,Float:X,Float:Y,Float:Z,Float:Angle,string[128],string2[128]; if(pAdmin[playerid] == 0) return SendClientMessage(playerid, Vermelho, "| ERRO | Vocк nгo tem permissгo!"); if(sscanf(params, "d",id))return SendClientMessage(playerid, Vermelho, "| ERRO | Digite: /cv [Id Do carro]"); if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,Vermelho, "| ERRO | Saia do seu veнculo atual primeiro!"); if(id==594)return SendClientMessage(playerid, Vermelho, "| ERRO | Veнculo Proibido!"); if(carroadmin[playerid] != 0){ DestroyVehicle(carroadmin[playerid]); Delete3DTextLabel(VeiculoADM[playerid]); } if(IsPlayerConnected(playerid)) { if(id >= 400 && id <= 611) { GetPlayerPos(playerid,X,Y,Z); GetPlayerFacingAngle(playerid,Angle); if(PlayerInfo[playerid][pAdminCamuflado] == 0)format(string2,sizeof(string2),"{DF01A5}Veнculo administrativo\n{%s}%s {FFFFFF}%s",GetCorAdmin(playerid),CargoAdmin(playerid),PlayerName(playerid)); carroadmin[playerid] = CreateVehicle(id, X, Y, Z, Angle, -1, -1, 120000); SetVehicleNumberPlate(carroadmin[playerid], "BCM-Admin"); VeiculoADM[playerid] = Create3DTextLabel(string2, 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 ); Attach3DTextLabelToVehicle(VeiculoADM[playerid],carroadmin[playerid], 0.0, 0.0, 0.0); PutPlayerInVehicle(playerid,carroadmin[playerid],0); if(GetPlayerInterior(playerid)) LinkVehicleToInterior(carroadmin[playerid],GetPlayerInterior(playerid)); format(string, sizeof(string), "| BCM-Admin | Vocк criou o veнculo {FFFFFF}'{0CB80C}%s{FFFFFF}' {1D76FC}ID {FFFFFF}'{0CB80C}%d{FFFFFF}' !", PlayerVehicle[GetVehicleModel(GetPlayerVehicleID(playerid))-400],id); SendClientMessage(playerid, adm, string); SendClientMessage(playerid, adm, "| INFO | Ao sair do veнculo ele serб automaticamente deletado!"); cVehicle[playerid] = true; return 1; } else { SendClientMessage(playerid, Vermelho, "| ERRO | ID invбlido | ID's = 400-611"); return 1; } } return 1; }
Uma dica, primeiro confirme que
* O usuбrio й admin * O usuбrio digitou valores entre 400 e 611 e se este й permitido * O usuбrio estб conectado * O usuбrio nгo estб em modo espectador * O usuбrio nгo estб em outro veiculo Do jeito que voce fez basta digitar o comando que tanto faz ele vai destruir o veiculo, mesmo se o usuбrio digitou coisas erradas. |
//OnPlayerConnect
carroadmin[playerid] = INVALID_VEHICLE_ID;
//OnPlayerDisconnect
if(carroadmin[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(carroadmin[playerid]);
}
PHP Code:
PHP Code:
|
CMD:cv(playerid)
{
if(meucarro[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(meucarro[playerid]);
meucarro[playerid] = INVALID_VEHICLE_ID;
}
return 1;
}
GuiLopez, tenta fazer isso:
Reseta a variбvel carroadmin tambйm junto, e faзa um teste. PHP Code:
|
new carroadmin[MAX_PLAYERS] = {INVALID_VEHICLE_ID, ...};
CMD:cv(playerid, params[])
{
if(pAdmin[playerid] == 0)
return SendClientMessage(playerid, Vermelho, "| ERRO | Vocк nгo tem permissгo!");
if(carroadmin[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(carroadmin[playerid]);
Delete3DTextLabel(VeiculoADM[playerid]);
carroadmin[playerid] = INVALID_VEHICLE_ID;
}
new
id, Float:iPos[4], string[128], string2[128];
if(sscanf(params, "d", id))
return SendClientMessage(playerid, Vermelho, "| ERRO | Digite: /cv [Id Do carro]");
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid,Vermelho, "| ERRO | Saia do seu veнculo atual primeiro!");
if(id == 594)
return SendClientMessage(playerid, Vermelho, "| ERRO | Veнculo Proibido!");
if(id < 400 && id > 611)
return SendClientMessage(playerid, Vermelho, "ID Invбlido de veнculo, IDS entre 400 e 611.");
GetPlayerPos(playerid, iPos[0], iPos[1], iPos[2]);
GetPlayerFacingAngle(playerid, iPos[3]);
if(PlayerInfo[playerid][pAdminCamuflado] == 0)format(string2,sizeof(string2),"{DF01A5}Veнculo administrativo\n{%s}%s {FFFFFF}%s",GetCorAdmin(playerid),CargoAdmin(playerid),PlayerName(playerid));
carroadmin[playerid] = CreateVehicle(id, iPos[0], iPos[1], iPos[2], iPos[3], 1, 1, -1, -1);
SetVehicleNumberPlate(carroadmin[playerid], "BCM-Admin");
VeiculoADM[playerid] = Create3DTextLabel(string2, 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
Attach3DTextLabelToVehicle(VeiculoADM[playerid],carroadmin[playerid], 0.0, 0.0, 0.0);
PutPlayerInVehicle(playerid, carroadmin[playerid], 0);
if(GetPlayerInterior(playerid) != 0)
{
LinkVehicleToInterior(carroadmin[playerid],GetPlayerInterior(playerid));
format(string, sizeof(string), "| BCM-Admin | Vocк criou o veнculo {FFFFFF}'{0CB80C}%s{FFFFFF}' {1D76FC}ID {FFFFFF}'{0CB80C}%d{FFFFFF}' !", PlayerVehicle[GetVehicleModel(GetPlayerVehicleID(playerid))-400],id);
SendClientMessage(playerid, adm, string);
SendClientMessage(playerid, adm, "| INFO | Ao sair do veнculo ele serб automaticamente deletado!");
cVehicle[playerid] = true;
}
return 1;
}
//Extra
public OnPlayerConnect(playerid)
{
carroadmin[playerid] = INVALID_VEHICLE_ID;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(carroadmin[playerid] != INVALID_VEHICLE_ID)
{
DestroyVehicle(carroadmin[playerid]);
Delete3DTextLabel(VeiculoADM[playerid]);
carroadmin[playerid] = INVALID_VEHICLE_ID;
}
return 1;
}
Tive que refazer esse cуdigo, estude ele.
Se ainda continuar esse erro, Percorra sua gamemode, e olha se os veнculos estгo indo para outros interiores ou Mundos diferentes do seu. PHP Code:
|