Repair vozila ne radi

Započeo Neckiy, Maj 07, 2021, 06:56:09 PRE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.

Problem(error/warning): Problem ovde je to sto RTVP radi ako sam ja u vozilu sa drugom i njemu fiksam, ali cim ja izadjem iz vozila, iskoci u chatu da sam mu popravio ali vozilo se ne popravi.
Deo skripte:
CMD:rtvp(playerid, params[]) // KAD NISAM U VOZILU NE RADI
{
	if(UlogovaniIgrac[playerid] == 0) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Niste ulogovani.");
	if(zamrznut[playerid] == 1) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Ne mozes to sad!");
	new name1[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],id,msg1[128],msg2[128],msgg[128];
	if(PlayerInfo[playerid][pAdmin] > 0 || PlayerInfo[playerid][pHelper] > 0)
	{
		new Float:health;
		new veh = GetPlayerVehicleID(id);
		GetVehicleHealth(veh, health);
		if(aduty[playerid] == 0 && hduty[playerid] == 0 && sduty[playerid] == 0) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Nisi na duznosti!");
		if(sscanf(params,"u",id)) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Ukucajte: /rtvp [ID]");
		if(!IsPlayerInAnyVehicle(id)) return SCM (playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Igrac nije u vozilu!");
		if(!IsPlayerConnected(id)) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Igrac nije online.");
		if(health == 1000) return SendClientMessage(playerid, -1, "{FF0000}[GRESKA] {FFFFFF}Vozilo ima full HP.");
		RepairVehicle(veh); SetVehicleHealth(veh, health);
		GetPlayerName(playerid, name1,sizeof(name1));
		GetPlayerName(id,name2,sizeof(name2));
		format(msg1,sizeof(msg1), "{FF0000}[GS:RP] {FFFFFF}%s {FFFB00}ti je popravio vozilo!",name1);
		format(msg2,sizeof(msg2), "{FF0000}[GS:RP] {FFFB00}Popravio si vozilo igracu {FFFFFF}%s{FFFB00}!",name2);
		format(msgg,sizeof(msgg),"{FFFB00}[AdminInfo] {FFFFFF}%s je popravio vozilo igracu %s!",name1,name2);
		SCM(id,-1,msg1);
		SCM(playerid,-1,msg2);
		NapisiHelperima(-1,msgg);
	}
	else return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Nisi ovlascen!");
	return 1;
}

Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log):
//
Mnogo ljudi mi govori da sam autistican.
U pravu su...

if (isnull(params)) {
RepairVehicle(playerid);
} else {
new targetid;

sscanf(params, "u", targetid);

if (targetid == INVALID_PLAYER_ID) {
 // Igrac nije online
}

RepairVehicle(targetid);
}

Ono kad koristis sscanf i opet proveravas je l invalid id  :'(

CMD:repairveh(playerid, const string: params[])
{
	if (isnull(params)) {
		SendClientMessage(playerid, -1, "/repairveh [targetid]");
		return 1;
	}

	if (strval(params) == INVALID_PLAYER_ID) {
		return 0;
	}

	if (!IsPlayerInAnyVehicle(strval(params))) {
		return 0;
	}

	// dodaj poruke i provere itd sta ti jos treba...
	RepairVehicle(GetPlayerVehicleID(strval(params)));
	SetVehicleHealth(GetPlayerVehicleID(strval(params)), Float: 999.0);

	return 1;
}

new Ppopravi[MAX_PLAYERS];

CMD:fv(playerid, params[]) {
	if(PlayerInfo[playerid][pAdmin] >= 1)
	{
		new player;
		if(sscanf(params, "U(-1)", player)) return SCM(playerid,NS_YELLOW, "[KORISCENJE] "BELA"/fv [ID/Ime_Prezime]");
		if(PlayerInfo[playerid][pVipSuspend] == 1 && PlayerInfo[playerid][pSuspendvip] > 0) return SCM(playerid,NS_ORANGE, "* Ne mozete koristiti ovu komandu dok ste suspendovani.");
		if(!IsPlayerConnected(player)) {
	     	if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,NS_ORANGE,"* Ovu komandu mozete koristiti samo dok ste u vozilu.");
			RepairVehicle(GetPlayerVehicleID(playerid));
            SCM(playerid,NS_YELLOW, "[INFO] "BELA"Popravili ste vase vozilo.");
		} else if(IsPlayerConnected(player)) {
	     	if(!IsPlayerInAnyVehicle(player)) return SCM(playerid,NS_ORANGE, "* Igrac mora biti u vozilu kako bi mu ga popravili.");
	     	if(PlayerInfo[player][pTrazeniLevel] >= 1) return SCM(playerid, NS_ORANGE, "* Ne mozes popravljati vozilo igracu koji ima trazeni level.");
			RepairVehicle(GetPlayerVehicleID(player));
			SetVehicleHealth(GetPlayerVehicleID(player), 999.0);
			new buffer[128]; GetPlayerName(player, buffer,MAX_PLAYER_NAME + 1);
            va_SendClientMessage(playerid,NS_YELLOW, "[INFO] "BELA"Popravili ste %s [%d] vozilo.",buffer,player);
            GetPlayerName(playerid, buffer,MAX_PLAYER_NAME + 1);
			format(buffer,sizeof buffer,"[INFO] "BELA"Staff %s vam je popravio vozilo.",buffer);
			SCM(player, NS_YELLOW, buffer);
		}
	}
    else if(PlayerInfo[playerid][pVip] >= 3 || PlayerInfo[playerid][pPromoter] >= 1)
	{
	    if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,NS_ORANGE,"* Ovu komandu mozete koristiti samo dok ste u vozilu.");
        if(gettime() < Ppopravi[playerid]) return SCM(playerid,NS_ORANGE, "* Vozilo se moze popravljati svakih 5 minuta.");
		RepairVehicle(GetPlayerVehicleID(playerid));
		SCM(playerid,NS_YELLOW, "[INFO] "BELA"Popravili ste vase vozilo.");
		SetPVarInt(playerid, "PopravkaVozila", 1);
		Ppopravi[playerid] = gettime() + 300;
	}
	else return SendClientMessage(playerid,NS_ORANGE,"* Nemate ovlascenje za upotrebu ove komande.");
	return 1;
}


E sad ti izbaci ono sto ti nemas na mogu.
Evo boja ako zelis
Bojeeeeeeeeee
#define NS_YELLOW       0xF3FF02FF
#define NS_ORANGE       0xFF6347AA

Poslednja Izmena: Maj 08, 2021, 00:34:58 PRE PODNE od M Ө M Σ N Z I

Aj napisi to u pawn kodu izbih oci pokusavajuci da procitam
Mnogo ljudi mi govori da sam autistican.
U pravu su...

mozel neko da me nauci kako da pisem u pawno codu ako moze?

Citat: Dime123 poslato Maj 08, 2021, 03:52:16 PRE PODNE
mozel neko da me nauci kako da pisem u pawno codu ako moze?
"[pawn]kod[/pawn"
bez navodnika samo a i imas ikonicu za pawn gore samo kliknes i pises kod

Uzimas vehicle id od igrača (id), pa tek onda varijabli id dodjeljujes vrijednost preko unosa, što će ti rezultirati da se igraču id 0 (uglavnom) popravlja vozilo. Nakon što varijabli id dodjelis vrijednost (sscanf) onda dodjeli varijablama poput veh vrijednost na osnovu varijable id, ovako tvoj sistem ne može raditi ispravno

CMD:rtvp(playerid, params[]) // KAD NISAM U VOZILU NE RADI
{
	if(UlogovaniIgrac[playerid] == 0) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Niste ulogovani.");
	if(zamrznut[playerid] == 1) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Ne mozes to sad!");
	if(PlayerInfo[playerid][pAdmin] > 0 || PlayerInfo[playerid][pHelper] > 0) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Nisi ovlascen!");
	if(aduty[playerid] == 0 && hduty[playerid] == 0 && sduty[playerid] == 0) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Nisi na duznosti!");

	new targetid;
	if(sscanf(params,"u",targetid)) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Ukucajte: /rtvp [ID]");

	if(!IsPlayerInAnyVehicle(targetid)) return SCM (playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Igrac nije u vozilu!");
	if(!IsPlayerConnected(targetid)) return SCM(playerid,-1,"{FF0000}[GRESKA] {FFFFFF}Igrac nije online.");

	new vehicleid = GetPlayerVehicleID(targetid);
	new Float:health;
	GetVehicleHealth(vehicleid, health);
	if(health == 1000) return SendClientMessage(playerid, -1, "{FF0000}[GRESKA] {FFFFFF}Vozilo ima full HP.");

	RepairVehicle(vehicleid); 
	SetVehicleHealth(vehicleid, 1000);

	new adminName[MAX_PLAYER_NAME],playerName[MAX_PLAYER_NAME]
	GetPlayerName(playerid, adminName, sizeof(adminName));
	GetPlayerName(targetid, playerName, sizeof(playerName));

	new string[144];
	format(string, sizeof(string), "{FF0000}[GS:RP] {FFFFFF}%s {FFFB00}ti je popravio vozilo!",adminName);
	SCM(targetid,-1,string);

	format(string, sizeof(string), "{FF0000}[GS:RP] {FFFB00}Popravio si vozilo igracu {FFFFFF}%s{FFFB00}!",playerName);
	SCM(playerid,-1,string);

	format(string, sizeof(string),"{FFFB00}[AdminInfo] {FFFFFF}%s je popravio vozilo igracu %s!",adminName,playerName);
	NapisiHelperima(-1, string);
	return 1;
}

Probaj tako, greske necu ni da navodim na kraju ispade da sam pola komande izmenio. I izmenio sam ti imena promenivih, da se zna sta je sta a ne ime1 i ime2 dje neznas sta je sta.