Jump to content

Ajutor string-Nelamurire


Se7en_Days

Recommended Posts

Yo, va salut pe toti. Am o problema legata de un string.

Aici este codul cu problema:

            new rang1[100];
			rang1 = "UNRANKED";
			PlayerInfo[playerid][pRang] = rang1;

Nu inteleg cum as putea ca la PlayerInfo[playerid][pRang] sa pun un text, nu un numar.

Eroarea este: error 006: must be assigned to an array

Daca ma poate indruma cineva, chiar nu imi dau seama ce trebuie facut.

Mersi!

Link to comment
Share on other sites

Ca sa copiezi string-uri trebuie sa te folosesti de strcat sau format. Pentru ceva simplu ca asta recomanda strcat

new rang1[100];
rang1 = "UNRANKED";
PlayerInfo[playerid][pRang] = '\0'; // Stergem orice ar putea fi aici ca sa nu copiem peste/langa

strcat(PlayerInfo[playerid][pRang], rang1, sizeof(PlayerInfo[playerid][pRang]));
//sau
format(PlayerInfo[playerid][pRang], sizeof(PlayerInfo[playerid][pRang]), "%s", rang1);

 

  • Upvote 1
Link to comment
Share on other sites

Acum 13 ore, Banditul a spus:

Ca sa copiezi string-uri trebuie sa te folosesti de strcat sau format. Pentru ceva simplu ca asta recomanda strcat

new rang1[100];
rang1 = "UNRANKED";
PlayerInfo[playerid][pRang] = '\0'; // Stergem orice ar putea fi aici ca sa nu copiem peste/langa

strcat(PlayerInfo[playerid][pRang], rang1, sizeof(PlayerInfo[playerid][pRang]));
//sau
format(PlayerInfo[playerid][pRang], sizeof(PlayerInfo[playerid][pRang]), "%s", rang1);

 

Mersi mult! Apreciez ajutorul.

Link to comment
Share on other sites

Acum 13 ore, Banditul a spus:

Ca sa copiezi string-uri trebuie sa te folosesti de strcat sau format. Pentru ceva simplu ca asta recomanda strcat

new rang1[100];
rang1 = "UNRANKED";
PlayerInfo[playerid][pRang] = '\0'; // Stergem orice ar putea fi aici ca sa nu copiem peste/langa

strcat(PlayerInfo[playerid][pRang], rang1, sizeof(PlayerInfo[playerid][pRang]));
//sau
format(PlayerInfo[playerid][pRang], sizeof(PlayerInfo[playerid][pRang]), "%s", rang1);

 

Faza e ca dupa ce dau compile, primesc o eroare fix la codul acesta: 

strcat(PlayerInfo[playerid][pRang], rang1, sizeof(PlayerInfo[playerid][pRang]));

Asta primesc:

error 001: expected token: "]", but found "-identifier-"

warning 215: expression has no effect

error 001: expected token: ";", but found "]"

error 029: invalid expression, assumed zero

fatal error 107: too many error messages on one line

 

 

Link to comment
Share on other sites

Acum 2 ore, Se7en_Days a spus:

Faza e ca dupa ce dau compile, primesc o eroare fix la codul acesta: 


strcat(PlayerInfo[playerid][pRang], rang1, sizeof(PlayerInfo[playerid][pRang]));

Asta primesc:

error 001: expected token: "]", but found "-identifier-"

warning 215: expression has no effect

error 001: expected token: ";", but found "]"

error 029: invalid expression, assumed zero

fatal error 107: too many error messages on one line

 

 

Poti sa imi arati cum ai trecut/definit pRang in enum pentru datele playerilor?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.