Jump to content
  • 0

Problema cu strcat


Punct.

Question

Nick: Punct.

Problema: Am facut niste textdraw-uri.. mai exact butoane pe care scrie A, B, C, D. Cand dai click pe ele sa se formeze alt textdraw si sa apara un cuvant format din ordonea in care apesi pe textdraw-uri A,B,C,D. Problema e ca mie imi facem mereu textdraw-ul litera pe care apas.. in loc sa mai adauge litera pe care apas la cuvantul care ar trebui sa se formeze.

Erori / warnings: -

Lini/script:

[pawn]

if (strcmp(cmd, "/test", true) == 0)

{

        if(IsPlayerConnected(playerid))

        {

            for(new t; t != sizeof(Login); ++t)

{

PlayerTextDrawShow(playerid, Login[t][playerid]);

}

opcptd[playerid] = 4;

SelectTextDraw(playerid, 0x00FF00FF);

        }

        return 1;

}

[/pawn]

[pawn]

public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)

{

if(opcptd[playerid] == 1) {//...}

else if(opcptd[playerid] == 2) {//...}

else if(opcptd[playerid] == 3) {//...}

else if(opcptd[playerid] == 4)

{

    new string[50], std[50];

    if(playertextid == Login[0][playerid])

    {

        strcat(string, "A");

        format(std, sizeof(std), "%s", string);

PlayerTextDrawSetString(playerid, Login[4][playerid], string);

PlayerTextDrawShow(playerid, Login[4][playerid]);

}

else if(playertextid == Login[1][playerid])

{

    strcat(string, "B");

        format(std, sizeof(std), "%s", string);

PlayerTextDrawSetString(playerid, Login[4][playerid], string);

PlayerTextDrawShow(playerid, Login[4][playerid]);

}

else if(playertextid == Login[2][playerid])

{

    strcat(string, "C");

        format(std, sizeof(std), "%s", string);

PlayerTextDrawSetString(playerid, Login[4][playerid], string);

PlayerTextDrawShow(playerid, Login[4][playerid]);

}

        else if(playertextid == Login[3][playerid])

        {

            strcat(string, "D");

        format(std, sizeof(std), "%s", string);

PlayerTextDrawSetString(playerid, Login[4][playerid], string);

PlayerTextDrawShow(playerid, Login[4][playerid]);

CancelSelectTextDraw(playerid);

}

}

return 1;

}

[/pawn]

[pawn]

  Login[0][playerid] = CreatePlayerTextDraw(playerid, 27.000000, 114.000000, "A");

PlayerTextDrawAlignment(playerid, Login[0][playerid], 2);

PlayerTextDrawBackgroundColor(playerid, Login[0][playerid], 255);

PlayerTextDrawFont(playerid, Login[0][playerid], 1);

PlayerTextDrawLetterSize(playerid, Login[0][playerid], 0.500000, 1.000000);

PlayerTextDrawColor(playerid, Login[0][playerid], -1);

PlayerTextDrawSetOutline(playerid, Login[0][playerid], 0);

PlayerTextDrawSetProportional(playerid, Login[0][playerid], 1);

PlayerTextDrawSetShadow(playerid, Login[0][playerid], 1);

PlayerTextDrawUseBox(playerid, Login[0][playerid], 1);

PlayerTextDrawBoxColor(playerid, Login[0][playerid], 255);

PlayerTextDrawTextSize(playerid, Login[0][playerid], 13.000000, 14.000000);

PlayerTextDrawSetSelectable(playerid, Login[0][playerid], 1);

Login[1][playerid] = CreatePlayerTextDraw(playerid, 47.000000, 114.000000, "B");

PlayerTextDrawAlignment(playerid, Login[1][playerid], 2);

PlayerTextDrawBackgroundColor(playerid, Login[1][playerid], 255);

PlayerTextDrawFont(playerid, Login[1][playerid], 1);

PlayerTextDrawLetterSize(playerid, Login[1][playerid], 0.500000, 1.000000);

PlayerTextDrawColor(playerid, Login[1][playerid], -1);

PlayerTextDrawSetOutline(playerid, Login[1][playerid], 0);

PlayerTextDrawSetProportional(playerid, Login[1][playerid], 1);

PlayerTextDrawSetShadow(playerid, Login[1][playerid], 1);

PlayerTextDrawUseBox(playerid, Login[1][playerid], 1);

PlayerTextDrawBoxColor(playerid, Login[1][playerid], 255);

PlayerTextDrawTextSize(playerid, Login[1][playerid], 13.000000, 14.000000);

PlayerTextDrawSetSelectable(playerid, Login[1][playerid], 1);

Login[2][playerid] = CreatePlayerTextDraw(playerid, 67.000000, 114.000000, "C");

PlayerTextDrawAlignment(playerid, Login[2][playerid], 2);

PlayerTextDrawBackgroundColor(playerid, Login[2][playerid], 255);

PlayerTextDrawFont(playerid, Login[2][playerid], 1);

PlayerTextDrawLetterSize(playerid, Login[2][playerid], 0.500000, 1.000000);

PlayerTextDrawColor(playerid, Login[2][playerid], -1);

PlayerTextDrawSetOutline(playerid, Login[2][playerid], 0);

PlayerTextDrawSetProportional(playerid, Login[2][playerid], 1);

PlayerTextDrawSetShadow(playerid, Login[2][playerid], 1);

PlayerTextDrawUseBox(playerid, Login[2][playerid], 1);

PlayerTextDrawBoxColor(playerid, Login[2][playerid], 255);

PlayerTextDrawTextSize(playerid, Login[2][playerid], 13.000000, 14.000000);

PlayerTextDrawSetSelectable(playerid, Login[2][playerid], 1);

Login[3][playerid] = CreatePlayerTextDraw(playerid, 87.000000, 114.000000, "D");

PlayerTextDrawAlignment(playerid, Login[3][playerid], 2);

PlayerTextDrawBackgroundColor(playerid, Login[3][playerid], 255);

PlayerTextDrawFont(playerid, Login[3][playerid], 1);

PlayerTextDrawLetterSize(playerid, Login[3][playerid], 0.500000, 1.000000);

PlayerTextDrawColor(playerid, Login[3][playerid], -1);

PlayerTextDrawSetOutline(playerid, Login[3][playerid], 0);

PlayerTextDrawSetProportional(playerid, Login[3][playerid], 1);

PlayerTextDrawSetShadow(playerid, Login[3][playerid], 1);

PlayerTextDrawUseBox(playerid, Login[3][playerid], 1);

PlayerTextDrawBoxColor(playerid, Login[3][playerid], 255);

PlayerTextDrawTextSize(playerid, Login[3][playerid], 13.000000, 14.000000);

PlayerTextDrawSetSelectable(playerid, Login[3][playerid], 1);

Login[4][playerid] = CreatePlayerTextDraw(playerid, 57.000000, 130.000000, "i");

PlayerTextDrawAlignment(playerid, Login[4][playerid], 2);

PlayerTextDrawBackgroundColor(playerid, Login[4][playerid], 255);

PlayerTextDrawFont(playerid, Login[4][playerid], 1);

PlayerTextDrawLetterSize(playerid, Login[4][playerid], 0.500000, 1.000000);

PlayerTextDrawColor(playerid, Login[4][playerid], -1);

PlayerTextDrawSetOutline(playerid, Login[4][playerid], 0);

PlayerTextDrawSetProportional(playerid, Login[4][playerid], 1);

PlayerTextDrawSetShadow(playerid, Login[4][playerid], 1);

PlayerTextDrawUseBox(playerid, Login[4][playerid], 1);

PlayerTextDrawBoxColor(playerid, Login[4][playerid], -205);

PlayerTextDrawTextSize(playerid, Login[4][playerid], 0.000000, 76.000000);

[/pawn]

Ai incercat sa rezolvi singur ?: Da.. am tot invartit string, std de la OnPlayerClickPlayerTextDraw.. dar mai mult m-am ametit.. :|

Cateva poze.. desi nu cred ca ajuta: http://imgur.com/a/tJWOK#0

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Tu initializez valorile in interior, adica atunci cand playerul da click pe textdraw.

Sa-ti explic. Cand se termina functia acele variabile se distrug, ele nu raman in memorie, astea o sa fie mereu initializate cu valoarea NULL, in PAWN parca era EOS. Daca vrei sa le pastrezi pune-le globale.

[pawn]new string[MAX_PLAYERS][50], std[MAX_PLAYERS][50];[/pawn]

Iar la OnPlayerConnect pune:

[pawn]string[playerid]= EOS;

std[playerid] = EOS;[/pawn]

pentru a le reseta.

In punctie le folosesti asa:

[pawn]strcat(string[playerid], "A");[/pawn]

respectiv

[pawn]format(std[playerid], sizeof(std[playerid]), "%s", string[playerid]);[/pawn]

Tot n-am vazut pentru ce folosesti variabila "std".

Link to comment
Share on other sites

Am pus variabila std pentru ca initial facusem ceva gen:

[pawn]

format(string, sizeof(string), "%s", std);

PlayerTextDrawSetString(playerid, Login[4][playerid], std);

PlayerTextDrawShow(playerid, Login[4][playerid]);

[/pawn]

Da.. stiu ca e o prostie ce am facut :))

Revin cu edit daca merge ce mi-ai zis mai sus..

Edit:

Bun. Daca nu pun alea la OnPlayerConnect merge perfect. Daca pun alea la OnPlayerConnect primesc doua erori...

(4640) : error 033: array must be indexed (variable "iText")
(4640) : error 033: array must be indexed (variable "iText2")

[pawn]new iText[MAX_PLAYERS][20], iText2[MAX_PLAYERS][20];[/pawn]

[pawn]public OnPlayerConnect(playerid)

{

//...

iText[playerid] = EOS; iText2[playerid] = EOS; // 4640

//...

}[/pawn]

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

Solved!

+1

Se poate da T.C.

Nu mai deschideti in pu*a mea servere de SA:MP !

Jucati-va pe cele care sunt !   Sunt suficiente !

Reguli de bun simt:

1. Nu faceti reclama unde nu trebuie !

2. Nu injurati ca la usa cortului !

3. Daca esti analfabeti, taci din gura !

4. Nu abuza de 'scuze', 'din greseala' !

 

My work ::: http://pastebin.com/VRNRcaAs

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.