Jump to content
  • 0

pomoc Jak převést pole na string


ForestCZE

Dotaz

Zdravím, potřeboval bych poradit. Mám tento kód v OnDialogResponse:

 

new test[128];
format(test, sizeof(test), "Heslo: %s", inputtext);
SendClientMessage(playerid, C_RED, test);

 Všechno funguje v pořádku, to heslo mi to vypíše. Já si to heslo potřebuji uložit, abych s ním mohl pracovat dál mimo funkci, takže mám něco jako:

 

new pass[MAX_PLAYERS];
pass[playerid] = inputtext;

To mi ale hází, že to musí být pole.

error 006: must be assigned to an array

Dokázal by mi někdo poradit? Díky :)

 

 

Link to comment
Share on other sites

3 odpovědí na tuto otázku

Recommended Posts

  • 2
new pass[MAX_PLAYERS];
pass[playerid] = inputtext;

Tato kontrukce je sice myslena dobře, ovšem lze použít jen u pole, kde je při kompilaci známá veikost. Což není tento případ.

Doporučuji použít

pass[playerid][0] = 0;//Pokud vis ze to bude prazdne, neni treba pouzit
strcat(pass[playerid],inputtext);

 

Link to comment
Share on other sites

  • 0
On 8. 2. 2018 at 20:45, ATomas said:

new pass[MAX_PLAYERS];
pass[playerid] = inputtext;

Tato kontrukce je sice myslena dobře, ovšem lze použít jen u pole, kde je při kompilaci známá veikost. Což není tento případ.

Doporučuji použít


pass[playerid][0] = 0;//Pokud vis ze to bude prazdne, neni treba pouzit
strcat(pass[playerid],inputtext);

 

Super, díky :)

Link to comment
Share on other sites

  • -3

new pass[MAX_PLAYERS] vytvorí pole obyčajných čísel a ty sa potom do obyčajného čísla snažíš priradiť string.. 

Riešenie erroru:

new pass[MAX_PLAYERS] => new pass[MAX_PLAYERS][128] (vytvorí pole stringov)

PS: určite si potrebuješ ukladať heslo hráča do premennej?  

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...