Jump to content
  • 0

pomoc Dotaz


MackoLuky

Dotaz

Když si udělám pomocí dini ukládání dotazy/dotazy.txt do kterých se mi bude ukládat

ID a vedle toho dotaz, můžu udělat pomocí dini že dám /příkaz id a přečte mi to ten dotaz? :d Potřeboval bych to prosím vědět, dík. :)

Link to comment
Share on other sites

23 odpovědí na tuto otázku

Recommended Posts

  • 0
  • Administrátor

A když hráč id jedna napíše ahoj tak se to uloží jako 1=Ahoj pak se odpojí přípojí se jinej taky bude mít id 1 napíš hoaj tak ti to přepíše ten původní :d

Link to comment
Share on other sites

  • 0

COMMAND:cist(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",playerid)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
	format(file, sizeof(file), DOTAZY, playerid);
       String = dini_Get(file, "Dotaz");
return 1;
}

COMMAND:dotaz(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <0) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(file, sizeof(file), DOTAZY, playerid);
	dini_Create(file);
       dini_Set(file, "Dotaz", String);
return 1;
}

Text se mi sice uloží, ale nevím jak načíst. :(

Link to comment
Share on other sites

  • 0
COMMAND:cist(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",playerid)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
	format(file, sizeof(file), DOTAZY, playerid);
       format(String, sizeof(String), "[ DOTAZ ] ID:%d: %s", strval(params), dini_Get(file, "Dotaz"));
       SendClientMessage(playerid, 0xFF0000FF, String);
	return 1;
}

COMMAND:dotaz(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <0) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(file, sizeof(file), DOTAZY, playerid);
	dini_Create(file);
       dini_Set(file, "Dotaz", params);
	return 1;
}

Link to comment
Share on other sites

  • 0
COMMAND:cist(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",playerid)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
	format(file, sizeof(file), DOTAZY, playerid);
       format(String, sizeof(String), "[ DOTAZ ] ID:%d: %s", strval(params), dini_Get(file, "Dotaz"));
       SendClientMessage(playerid, 0xFF0000FF, String);
	return 1;
}

COMMAND:dotaz(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <0) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(file, sizeof(file), DOTAZY, playerid);
	dini_Create(file);
       dini_Set(file, "Dotaz", params);
	return 1;
}

Tw, ajo :d Já sem si nemohl vzpomenout že dini_Get mohu dávat do formátu, omg :d Díky moc. ;)

Link to comment
Share on other sites

  • 0
použij:

fwrite,fread,fremove.

A jak s fwrite, protože to mi vytvoří soubor s názvem který si vytvořím v pawnu ne?

new File:Soubor = fopen("text.txt", io_write);

A název to bude mýt tento, jak pak přečtu tu zprávu když odešle zprávu třeba 5 lidí? :d, spíše jak udělám pro každýho soubor který se bude jmenovat podle jeho ID ? :o

Link to comment
Share on other sites

  • 0

format(x,sizeof(x),"%s.txt",Jmeno(playerid));//format s nickem

new File:Soubor = fopen(x, io_write);//vytvori a otevre soubor: "Nick.txt"

a pak při čtení jen

format(x,sizeof(x),"%s.txt",Jmeno(playerid));//format

fread(Soubor, string);//precte

format(aa,sizeof(aa),"%s",string);//format

printf(string);//zapise obsah

fclose(Soubor);//zavre

 

nějak tak,nevím.

nekontroloval jsem to

samozřejmě si to musíš ještě upravit.

Link to comment
Share on other sites

  • 0
format(x,sizeof(x),"%s.txt",Jmeno(playerid));//format s nickem

new File:Soubor = fopen(x, io_write);//vytvori a otevre soubor: "Nick.txt"

a pak při čtení jen

format(x,sizeof(x),"%s.txt",Jmeno(playerid));//format

fread(Soubor, string);//precte

format(aa,sizeof(aa),"%s",string);//format

printf(string);//zapise obsah

fclose(Soubor);//zavre

 

nějak tak,nevím.

nekontroloval jsem to

samozřejmě si to musíš ještě upravit.

Já to udělám přes tu dini však to přes ní jde :d

Link to comment
Share on other sites

  • 0

COMMAND:cist(playerid,params[])
{
	new id;
       if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
	format(file, sizeof(file), DOTAZY, id);
       format(String, sizeof(String), "[ DOTAZ ] ID:%d: %s", id, dini_Get(file, "Dotaz"));
       SendClientMessage(playerid, COLOR_RED, String);
     return 1;
}

COMMAND:dotaz(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <0) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(file, sizeof(file), DOTAZY, playerid);
       dini_Create(file);
       dini_Set(file, "Dotaz", params);
     return 1;
}

Už přečtu moji zprávu tudíž /cist 0 ale když mám dotaz od id 1 a dám /cist 1 tak mi to píše unknown command :/

Link to comment
Share on other sites

  • 0
Nejlepší je to zapsat do databáze je klid

Ewwe prosím pomoc :d Ty to určitě vykoumáš :d Už od toho chci mýt klid :d

 

COMMAND:cist(playerid,params[])
{
	new id;
       if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
	format(file, sizeof(file), DOTAZY, id);
       format(String, sizeof(String), "[ DOTAZ ] ID:%d: %s", id, dini_Get(file, "Dotaz"));
       SendClientMessage(playerid, COLOR_RED, String);
     return 1;
}

COMMAND:dotaz(playerid,params[])
{
       if(PlayerInfo[playerid][pAdminLevel] <0) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(sscanf(params,"s",String)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(file, sizeof(file), DOTAZY, playerid);
       dini_Create(file);
       dini_Set(file, "Dotaz", params);
     return 1;
}

 

V tomto kódě můžu přešíst pouze svůj dotaz, potřebuju už jen vědět jak mám ostatních, když dám /cist 1 tak mi to pise unknown command :d

Link to comment
Share on other sites

  • 0

toto ti musi fungovat, mas tam uplne cely kod:

COMMAND:cist(playerid,params[])
{
	new id = strval(params);
	new fileway[64];
	new String[200];
       //if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
       if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Nemôžeš čítať dotaz od nepripojeného ID !");
	format(fileway, sizeof(fileway), "Dotazy/dotaz%03d.txt", id);
	if(!fexist(fileway)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Tento dotaz neexistuje !");
       format(String, sizeof(String), "[ DOTAZ ] ID:%d: %s", id, dini_Get(fileway, "Dotaz"));
       SendClientMessage(playerid, COLOR_RED, String);
	return 1;
}

COMMAND:dotaz(playerid,params[])
{
	new fileway[64];
       if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(fileway, sizeof(fileway), "Dotazy/dotaz%03d.txt", playerid);
       dini_Create(fileway);
       dini_Set(fileway, "Dotaz", params);
	return 1;
}

//==========================================

public OnPlayerDisconnect(playerid)
{
	new fileway[64];
       format(fileway, sizeof(fileway), "Dotazy/dotaz%03d.txt", playerid);
       if(fexist(fileway)) fremove(fileway);
	return 1;
}

Link to comment
Share on other sites

  • 0
toto ti musi fungovat, mas tam uplne cely kod:

COMMAND:cist(playerid,params[])
{
	new id = strval(params);
	new fileway[64];
	new String[200];
       //if(PlayerInfo[playerid][pAdminLevel] <1) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Ani to nezkoušej!  Nejsi admin!");
       if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /cist [iD]!");
       if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Nemôžeš čítať dotaz od nepripojeného ID !");
	format(fileway, sizeof(fileway), "Dotazy/dotaz%03d.txt", id);
	if(!fexist(fileway)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Tento dotaz neexistuje !");
       format(String, sizeof(String), "[ DOTAZ ] ID:%d: %s", id, dini_Get(fileway, "Dotaz"));
       SendClientMessage(playerid, COLOR_RED, String);
	return 1;
}

COMMAND:dotaz(playerid,params[])
{
	new fileway[64];
       if(!strlen(params)) return SendClientMessage(playerid,COLOR_RED,"{ff0000}[ ! ] {ffffff}Použíj /dotaz [TEXT]!");
       format(fileway, sizeof(fileway), "Dotazy/dotaz%03d.txt", playerid);
       dini_Create(fileway);
       dini_Set(fileway, "Dotaz", params);
	return 1;
}

//==========================================

public OnPlayerDisconnect(playerid)
{
	new fileway[64];
       format(fileway, sizeof(fileway), "Dotazy/dotaz%03d.txt", playerid);
       if(fexist(fileway)) fremove(fileway);
	return 1;
}

Funguje, díky moc :)

LOCK

Link to comment
Share on other sites

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