CMD:veh

Započeo [CH]Tarik_Conell, Oktobar 06, 2018, 15:19:03 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Problem(error/warning): Uradio sam cmd /veh i nikako da rijesim problem kada stvorim auto, i izadjem iz njega napravljeno je u komandi da unisti vozilo, ali ga respawna na lokaciju gdje je stvoren
Dio skripte:
[ pawn ]CMD:veh(playerid,params[])
{
   new car;
   new string[128];
   new Float:X, Float:Y, Float:Z;
   if(PI[playerid][pAdmin] >= 1)
   {
      GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
      if(sscanf(params,"i", car)) return SendClientMessage(playerid, COLOR_SIVA,"Koristi: /Veh <ID 400 - 611>");
      if(car < 400 || car >611) return SendClientMessage(playerid, -1, ""CRVENA"[BG:RP] "BIJELA"Ne mozes koristiti id ispod 400 ili preko 611.");
      {
         if(Vehicle[playerid] != 0)
           DestroyVehicle(Vehicle[playerid]);
       }
       Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
       format(string,sizeof(string),""PLAVA"[BG:RP] "BIJELA"Stvorili ste vozilo pod ID-om %i",car);
       SendClientMessage(playerid, -1, string);
       PutPlayerInVehicle(playerid, Vehicle[playerid], 0);
   }
   else SCM(playerid, -1, ""CRVENA"[BG:RP] "BIJELA"Niste u mogucnosti koristiti ovu komandu!");
   return 1;
}[ /pawn ]
Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): [ code ]//[ /code ]
Slika/video ingame problema(obavezno ako je ingame problem): //
Poslednja Izmena: Oktobar 08, 2018, 18:24:03 POSLE PODNE od Bašovski


CMD:veh(playerid, params[]) {
if(Vehicle[playerid] != 0) {
DestroyVehicle(Vehicle[playerid]);
Vehicle[playerid] = 0;
}
else {
if (isnull(params)) return SendClientMessage(playerid, COLOR_SIVA,"Koristi: /Veh <ID 400 - 611>");
new car = strval(params);
if(car < 400 || car >611) return SendClientMessage(playerid, -1, ""CRVENA"[BG:RP] "BIJELA"Ne mozes koristiti id ispod 400 ili preko 611.");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
new vehicleid = Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
format(string,sizeof(string),""PLAVA"[BG:RP] "BIJELA"Stvorili ste vozilo pod ID-om %i",car);
SendClientMessage(playerid, -1, string);
PutPlayerInVehicle(playerid, vehicleid , 0);
}
}

Citat: .ксундер poslato Oktobar 06, 2018, 15:41:38 POSLE PODNE

CMD:veh(playerid, params[]) {
if(Vehicle[playerid] != 0) {
DestroyVehicle(Vehicle[playerid]);
Vehicle[playerid] = 0;
}
else {
if (isnull(params)) return SendClientMessage(playerid, COLOR_SIVA,"Koristi: /Veh <ID 400 - 611>");
new car = strval(params);
if(car < 400 || car >611) return SendClientMessage(playerid, -1, ""CRVENA"[BG:RP] "BIJELA"Ne mozes koristiti id ispod 400 ili preko 611.");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
new vehicleid = Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
format(string,sizeof(string),""PLAVA"[BG:RP] "BIJELA"Stvorili ste vozilo pod ID-om %i",car);
SendClientMessage(playerid, -1, string);
PutPlayerInVehicle(playerid, vehicleid , 0);
}
}


ne radi brate, ne mogu da skontam nikako sta je problem, kad izadjem iz auta ili ga unistim trebalo bi da ga skroz unisti sa servera, ali ga spawna na lokaciju gdje sam kucao /veh i u drugoj boji ga stvori

stavi ovo u new-ove
[pawn]new AdminVozilo[MAX_PLAYERS];[/pawn]
[pawn]new vozilo1;[/pawn]

[pawn]CMD:veh(playerid, params[])
{
   new Float:Pos[4];
   GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
   if(PlayerInfo[playerid][pGM] >= 1 || PlayerInfo[playerid][pAdmin] >= 1)
   {
      if(AdminVozilo[playerid] == -1)
      {
         vozilo1 = CreateVehicle(411,Pos[0],Pos[1],Pos[2],Pos[3],random(1),random(1),500);
         PutPlayerInVehicle(playerid,vozilo1,0);
         AdminVozilo[playerid] = vozilo1;
         SCM(playerid,-1,"[BG:RP]"ZELENA"Stvorili ste Admin & GM Vozilo.");
         new engine, lights, alarm, doors, bonnet, boot, objective;
         GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
         SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
      }
      else if(AdminVozilo[playerid] != -1)
      {
         DestroyVehicle(AdminVozilo[playerid]);
         AdminVozilo[playerid] = -1;
         SCM(playerid,-1,"[BG:RP]"ZELENA"Unistili ste Admin & GM Vozilo.");
      }
   }
   else return SCM(playerid,-1,""ZELENA"[BG-RP]"SIVA"Samo Admini & GameMasteri.");
   return 1;
}[/pawn]

probaj ovako da stvoriš samo infernusa. Mislim da je problem u tome sto biras koje ces auto, nisam siguran.


new adminVehicle[MAX_PLAYERS] = { INVALID_VEHICLE_ID, ... };

// OnPlayerConnect
adminVehicle[playerid] = INVALID_VEHICLE_ID;

// Komanda
CMD:veh(playerid, params[]) {
if (adminVehicle[playerid] == INVALID_VEHICLE_ID) {
if (isnull(params))
return SendClientMessage(playerid, -1, "/veh [Model ID]");

new modelid = strval(params);

if (400 > modelid > 611)
return SendClientMessage(playerid, -1, "* Validni modeli su od 400 do 611.");

new vehicleid = adminVehicle[playerid] = CreateVehicle(modelid, x, y, z, 0.0, random(100), random(100), -1);
PutPlayerInVehicle(playerid, vehicleid, 0);

SendClientMessage(playerid, -1, "Stvorili ste vozilo, da ga unistite kucajte '/veh'.");
}
else {
DestroyVehicle(adminVehicle[playerid]);
adminVehicle[playerid] = INVALID_PLAYER_ID;

SendClientMessage(playerid, -1, "Unistili ste vozilo, da ga stvorite kucajte '/veh [Model ID]'.");
}
return 1;
}


evo savrseno radi :D

Citat: .ксундер poslato Oktobar 07, 2018, 12:26:10 POSLE PODNE

new adminVehicle[MAX_PLAYERS] = { INVALID_VEHICLE_ID, ... };

// OnPlayerConnect
adminVehicle[playerid] = INVALID_VEHICLE_ID;

// Komanda
CMD:veh(playerid, params[]) {
if (adminVehicle[playerid] == INVALID_VEHICLE_ID) {
if (isnull(params))
return SendClientMessage(playerid, -1, "/veh [Model ID]");

new modelid = strval(params);

if (400 > modelid > 611)
return SendClientMessage(playerid, -1, "* Validni modeli su od 400 do 611.");

new vehicleid = adminVehicle[playerid] = CreateVehicle(modelid, x, y, z, 0.0, random(100), random(100), -1);
PutPlayerInVehicle(playerid, vehicleid, 0);

SendClientMessage(playerid, -1, "Stvorili ste vozilo, da ga unistite kucajte '/veh'.");
}
else {
DestroyVehicle(adminVehicle[playerid]);
adminVehicle[playerid] = INVALID_PLAYER_ID;

SendClientMessage(playerid, -1, "Unistili ste vozilo, da ga stvorite kucajte '/veh [Model ID]'.");
}
return 1;
}


evo savrseno radi :D
Eto dobro je uzivasj hahah :D

Citat: .ксундер poslato Oktobar 07, 2018, 12:26:10 POSLE PODNE

new adminVehicle[MAX_PLAYERS] = { INVALID_VEHICLE_ID, ... };

// OnPlayerConnect
adminVehicle[playerid] = INVALID_VEHICLE_ID;

// Komanda
CMD:veh(playerid, params[]) {
if (adminVehicle[playerid] == INVALID_VEHICLE_ID) {
if (isnull(params))
return SendClientMessage(playerid, -1, "/veh [Model ID]");

new modelid = strval(params);

if (400 > modelid > 611)
return SendClientMessage(playerid, -1, "* Validni modeli su od 400 do 611.");

new vehicleid = adminVehicle[playerid] = CreateVehicle(modelid, x, y, z, 0.0, random(100), random(100), -1);
PutPlayerInVehicle(playerid, vehicleid, 0);

SendClientMessage(playerid, -1, "Stvorili ste vozilo, da ga unistite kucajte '/veh'.");
}
else {
DestroyVehicle(adminVehicle[playerid]);
adminVehicle[playerid] = INVALID_PLAYER_ID;

SendClientMessage(playerid, -1, "Unistili ste vozilo, da ga stvorite kucajte '/veh [Model ID]'.");
}
return 1;
}


evo savrseno radi :D

Radi sad skonto sam problem je u ovome sto nisam definisao admincar;
Fali ovdje u ovoj cmd samo provjera za admina i GetPlayerPos jer te spawna u autu na farmi negdje ili propadas, sredio sam sve hvala tako da moze lock