Jump to content

Cerere tutorial textdraw ioin / leave


Andrey003

Recommended Posts

Descriere tutorial: Am un serve cu gm PPC_Trucking si de cateva zile incerc sa ii pun un textdraw care sa arate playerii care intra si care ies de pe server.

In PPC_DefTexts am definite TXT_PlayerJoinedServer si TXT_PlayerLeaveServer - astea sunt textele

Vreau un tutorial cum pot aduga acel texdraw..daca se poate sa apara maxim 3 randuri si sa fie in box

Link to comment
Share on other sites

In primul rand adaugi asta undeva in gamemode. Pe la inceput.

 

[pawn]new Text:PlayerJoinedServerTextDraw;[/pawn]

 

Cu asta facem o variabila in care o sa stocam ID-ul textdraw-ului.

 

Dupa ce am facut asta la OnGameModeInit adaugam

 

[pawn]PlayerJoinedServerTextDraw = TextDrawCreate(250.0, 426.0, " ");
TextDrawAlignment(PlayerJoinedServerTextDraw, 2);
TextDrawUseBox(PlayerJoinedServerTextDraw, 1);
TextDrawBoxColor(PlayerJoinedServerTextDraw, 0x00000066);
TextDrawFont(PlayerJoinedServerTextDraw, 1);
TextDrawSetShadow(PlayerJoinedServerTextDraw, 1);[/pawn]

 

Aici, creem textdraw-ul si ii setam proprietatiile.

 

Dupa care la OnPlayerConnect si OnPlayerDisconnect adaugam

 

[pawn]new String[64], PlayerName[MAX_PLAYER_NAME];

GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
format(String, sizeof(String), "%s a intrat pe server", PlayerName);
TextDrawSetString(PlayerJoinedServerTextDraw, String);
TextDrawShowForAll(PlayerJoinedServerTextDraw);
SetTimer("HideTextDraw",5000,false);[/pawn]

 

[pawn]new String[64], PlayerName[MAX_PLAYER_NAME];[/pawn] aici facem doua variabile in care o sa tinem minte textul pe care il afisem si numele jucatorului.

[pawn]GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);[/pawn] aici luam numele jucatorului si il punem in variabila PlayerName.

[pawn]TextDrawSetString(PlayerJoinedServerTextDraw, String);
TextDrawShowForAll(PlayerJoinedServerTextDraw);[/pawn] aici setam textul textdraw-ului si il afisem la toti jucatorii online.

[pawn]SetTimer("HideTextDraw", 5000, false);[/pawn] facem sa dispara textdraw-ul dupa 5 secunde.

 

Si ultimul pas adaugam

 

[pawn]forward HideTextDraw();
public HideTextDraw()
{
   TextDrawHideForAll(PlayerJoinedServerTextDraw);
   return 1;
}[/pawn]

 

Care o sa faca ca textdraw-ul cu ID-ul stocat in variabila PlayerJoinedServerTextDraw sa fie ascuns pentru toti jucatorii.

Link to comment
Share on other sites

Am facut tot ce mi-ai zis si am aceste errori

[pawn]
(175) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
(176) : error 035: argument type mismatch (argument 2)
(177) : warning 213: tag mismatch
(175) : warning 204: symbol is assigned a value that is never used: "PlayerName"
(622) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
(623) : error 035: argument type mismatch (argument 2)
(624) : warning 213: tag mismatch
(622) : warning 204: symbol is assigned a value that is never used: "PlayerName"
[/pawn]
 
si liniile
[pawn]
(175)    new String[64], PlayerName[MAX_PLAYER_NAME];
(176)    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
(177)    format(String, sizeof(String), "%s a intrat pe server", PlayerName);
(622)    new String[64], PlayerName[MAX_PLAYER_NAME];
(623)    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
(624)    format(String, sizeof(String), "%s a intrat pe server", PlayerName);
(625)    TextDrawSetString(PlayerJoinedServerTextDraw, String
[/pawn]
 
si uite cum imi apare in consola 
La conectare:
[pawn]
format(NewPlayerMsg, 128, TXT_PlayerJoinedServer, Name, playerid);
SendClientMessageToAll(0xFFFFFFFF, NewPlayerMsg);
[/pawn]
La deconectare:
[pawn]
format(Msg, 128, TXT_PlayerLeftServer, Name, playerid);
SendClientMessageToAll(0xFFFFFFFF, Msg);

[/pawn]

 

asa imi aparea inainte ....

Link to comment
Share on other sites

erorile

[pawn]

(175) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
(176) : error 035: argument type mismatch (argument 2)
(177) : warning 213: tag mismatch
(175) : warning 204: symbol is assigned a value that is never used: "PlayerName"
[/pawn]
 
  1. liniile
  2. (175)  new String[64], PlayerName[MAX_PLAYER_NAME];
  3. (176)  GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
  4. (177)  format(String, sizeof(String), "%s a intrat pe server", PlayerName);
Link to comment
Share on other sites

Acum imi apar aceste warninguri 

[pawn]
(175) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
(176) : warning 202: number of arguments does not match definition
(176) : warning 202: number of arguments does not match definition
(177) : warning 213: tag mismatch
(175) : warning 204: symbol is assigned a value that is never used: "PlayerName"
[/pawn]
 
am incercat sa intru in server si scrie jos y a intrat pe server iar apoi ma scoate si se inchide sever-ul,,,iar login la inceput nu mai apare ..
 
si ti-am spus ca eu am niste texte definite alea nu ar trebui sa fie adaugate aici?
Link to comment
Share on other sites

Ce texte definite? In primul rand, unde ai tu acele warning-uri. Arata tot warning-ul nu sterge si prima parte ... Adica unde se afla fisierul, poate sa fie dintr-un include si nu pot sa-mi dau seama daca e din gamemode sau nu.

 

Tu unde ai adaugat alea?

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.