[Ajuda] Trancar [carid] -
JuniorRiddle - 16.04.2012
Eu tava tentando fazer um comando pra trancar um carro pela placa, sem a nescessidade de estar dentro dele, usei um comando que eu achei logo no comeзo da minha pesquisa em pawn como base, e tentei adicionar os parametros, porйm, infelizmente ele compila no GM mas й infuncional, alguйm poderia apontar onde eu estou errando? Grato!
pawn Code:
if (strcmp(cmdtext, "/trancarc", true)==0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /trazercarro [carro id]");
return 1;
}
new i;
for(i=0;i<MAX_PLAYERS;i++)
{
if(i != playerid)
{
new carid = strval(tmp);
VTrancado[carid] = 1;
LockCar(carid);
}
}
SendClientMessage(playerid, 0x33AA33AA, "Veiculo Trancado");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
}
return 1;
}
Re: [Ajuda] Trancar [carid] -
ViniBorn - 16.04.2012
Qual a lуgica disso?
Re: [Ajuda] Trancar [carid] -
ScrashOff - 16.04.2012
Quote:
Originally Posted by Viniborn
|
Pelo jeito й para nгo dar lock para o si mesmo, e sim para os outros players.
Voltando ao assunto do tуpico, tente assim: (Caso nгo funcione, poste a funзгo LockCar)
pawn Code:
if(strcmp(cmdtext, "/trancarc", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
new carid = strval(tmp);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /trancarc [carro id]");
return 1;
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && i != playerid)
{
VTrancado[carid] = 1;
LockCar(carid);
}
}
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SendClientMessage(playerid, 0x33AA33AA, "Veiculo Trancado");
}
return 1;
}
Re: [Ajuda] Trancar [carid] -
paulor - 16.04.2012
Quote:
Originally Posted by ScrashOff
Pelo jeito й para nгo dar lock para o si mesmo, e sim para os outros players.
Voltando ao assunto do tуpico, tente assim: (Caso nгo funcione, poste a funзгo LockCar)
pawn Code:
if(strcmp(cmdtext, "/trancarc", true) == 0) { if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); new carid = strval(tmp); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USE: /trancarc [carro id]"); return 1; } for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && i != playerid) { VTrancado[carid] = 1; LockCar(carid); } } PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0); SendClientMessage(playerid, 0x33AA33AA, "Veiculo Trancado"); } return 1; }
|
What ?
Re : [Ajuda] Trancar [carid] -
JuniorRiddle - 16.04.2012
O Jeito que o Scrash ensinou nгo funcionou, eu removi aquele "if(i != playerid)" nгo era pra estar ali mesmo, eu tava com sono e acabei me enrrolando, mas voltando ao assunto, ainda nгo consegui fazer funcionar, /trancar [placa] eu sу c onsigo fazer funcionar se eu adaptar o comando para trancar o carro de dentro dele, mas isso й meio sem logica, afinal se eu tiver que estar dentro para /tranca ou /destrancar, fica muito estranho, alguma sugestгo, ou base para eu fazer o comando como eu quero? /trancar [placa/id do carro]
Re: [Ajuda] Trancar [carid] -
zSuYaNw - 16.04.2012
Consegui desenvolvi assim:
pawn Code:
// TOPO
new
vNumber[MAX_VEHICLES][100]
;
#define SetVehicleNumberPlate iSetVehicleNumberPlate
// OnPlayerCommandText
if(strcmp(cmd, "/trancarc", true) == 0)
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /trancarc [placa]");
new veh;veh = CreateVehicle(522, 0.0, 0.0,0.0, 0.0, -1, -1, 9); DestroyVehicle(veh);
for(new v; v != veh; ++v){
if(!strcmp(vNumber[v], tmp, true)){
for(new i, e = GetMaxPlayers(); i != e; ++i){
if(IsPlayerConnected(i)){
if(i != playerid){
VTrancado[carid] = 1;
LockCar(carid);
}
}
}
}
}
return 1;
}
SetVehicleNumberPlate(51, #OOL);
return 0;
}
// Final do GameMode
stock iSetVehicleNumberPlate(vehid, name[])
{
format(vNumber[vehid], strlen(name),"%s", name);
return 1;
}
Re : [Ajuda] Trancar [carid] -
JuniorRiddle - 17.04.2012
Bem, Garfield obrigado mas seu comando nгo funcionou (muitos erros warnigs ao compilar), depois de analizar muito eu comeзei um comando do zero e ele realmente ficou como eu queria, agradecimento a todos que tentaram me ajudar, grande abraзo.