Jump to content
  • 0

pomoc Smazání souboru


Mishak

Dotaz

Zdravím všechny, dělám si menší Admin systém a přidal jsem nově funkci Unban Nicku, mělo by to fungovat tak, že se otevře Dialog Input, tam se napíše nic hráče a mělo by mu to dát nick unban. Když dám někomu Nick Ban, tak se mi v SF, ve složce bans vytvoří soubor se jménem hráče, kterému jsem dal ban, no a ta funkce Nick Unban by tento soubor měla právě odstranit, jenže tomu tak není, proto se obracím sem.

 

 

 

	if(dialogid == 26)
	{
	    if(response)
	    {
			if(!strlen(inputtext))
			{
				SendClientMessage(playerid,0x99CC00,"Musíš napsat Nick hráče!");
				ShowPlayerDialog(playerid,26,DIALOG_STYLE_INPUT,"Nick Unban","Zadejte Nick hráče:","Unban","Zrusit");
			}
			else
			{
				new jmeno = strval(inputtext);
   				new soubor[256];
   				new str[128];
			    format(soubor, sizeof(soubor), BAN, jmeno);
			    format(str,128,"Dal jste unban hráči %s", jmeno);
			    if(fexist(soubor))
			    {
			        SendClientMessage(playerid,0xFF0000FF ,str);
					dini_Remove(soubor);
				}
			    if (!dini_Exists(soubor))
			    {
			        SendClientMessage(playerid,0xFF0000FF ,"Tento hráč nemá Nick Ban!");
			    }
		    }
		}
	}

 

 

Link to comment
Share on other sites

4 odpovědí na tuto otázku

Recommended Posts

  • 0
if(dialogid == 26)
	{
	    if(response)
	    {
			if(!strlen(inputtext))
			{
				SendClientMessage(playerid,0x99CC00,"Musíš napsat Nick hráče!");
				ShowPlayerDialog(playerid,26,DIALOG_STYLE_INPUT,"Nick Unban","Zadejte Nick hráče:","Unban","Zrusit");
			}
			else
			{
				
   			    new soubor[256];
   			    new str[128];
			    format(soubor, sizeof(soubor), BAN, inputtext);
			    format(str,128,"Dal jste unban hráči %s", inputtext);
			    
			    if(fexist(soubor))
			    {
			        SendClientMessage(playerid,0xFF0000FF ,str);
				dini_Remove(soubor);
			    }
			    else
			    {
			        SendClientMessage(playerid,0xFF0000FF ,"Tento hráč nemá Nick Ban!");
			    }
		    }
		}
	}

Přeči si k čemu se používá strval. Někdy si to stačí printnout nebo vypsat do hry, jak vypadá cesta k cíli...

Edited by Dandys 
Link to comment
Share on other sites

  • 0

~> Proč nešetříte?

 

	if (dialogid == 26)
	{
		if (!response) return (true);
		if (!strlen(inputtext)) return ShowPlayerDialog(playerid,26,DIALOG_STYLE_INPUT,"Nick Unban","Zadejte Nick hráče:","Unban","Zrusit");
		new 
			soubor[50 + 1], 
			str[70 + 1];
		format(soubor, sizeof(soubor), BAN, inputtext);
		if (!DOF2_FileExists(soubor)) return SendClientMessage(playerid,0xFF0000FF ,"Tento hráč nemá Nick Ban!");
		format(str, sizeof(str),"Dal jste unban hráči %s", inputtext);
		SendClientMessage(playerid,0xFF0000FF ,str);
		DOF2_RemoveFile(soubor);
		return (true);
	}
Link to comment
Share on other sites

  • 0

Dobře, díky moc. Ještě mám teda doplňující otázku.. Strlen určuje počet písmen  v hranatých závorkách u stringu? Jakože new str[číslo]? Aby to nebylo zbytečně moc, třeba když tam dám 128 a je jich tam jen 23? 

Link to comment
Share on other sites

  • 0

Dobře, díky moc. Ještě mám teda doplňující otázku.. Strlen určuje počet písmen  v hranatých závorkách u stringu? Jakože new str[číslo]? Aby to nebylo zbytečně moc, třeba když tam dám 128 a je jich tam jen 23?

Return Values:

The length of the string as an integer.

(http://wiki.sa-mp.com/wiki/Strlen)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...