10.08.2011, 17:53
Hello.
I do a textdraw editor.
It is almost finished, only missing the registration code in the file.
I just test it, I had a problem with the colors, so I switched to another method.
Now, with the / create, I have no message ...
Thank you in advance!
Here is my code:
I do a textdraw editor.
It is almost finished, only missing the registration code in the file.
I just test it, I had a problem with the colors, so I switched to another method.
Now, with the / create, I have no message ...
Thank you in advance!
Here is my code:
Code:
#include "a_samp" #include "colors" #define SUCCESS 0x21DD00FF #define ERROR 0xE60000FF #define INFO 0x00C2ECFF #define MAX_TEXTDRAWS 200 enum ETextDrawInfos { Float:ETextDrawX, Float:ETextDrawY, ETextDrawContent[256], ETextDrawColor, ETextDrawFont, Float:ETextDrawLetterSizeWidth, Float:ETextDrawLetterSizeHeight, Float:ETextDrawSetOutline, Float:ETextDrawSetShadow, ETextDrawSetProportional, ETimerStatus, ETimerID } new ETextDrawData[MAX_TEXTDRAWS][ETextDrawInfos]; new ActTextDraw = 0; new Text:TD; new CanCreate[MAX_PLAYERS]; new IsInCreate[MAX_PLAYERS]; public OnPlayerConnect(playerid) { IsInCreate[playerid] = 0; CanCreate[playerid] = 0; return 1; } public OnPlayerSpawn(playerid) { CanCreate[playerid] = 1; return 1; } public OnPlayerDeath(playerid, killerid, reason) { CanCreate[playerid] = 0; return 1; } public OnPlayerDisconnect(playerid, reason) { CanCreate[playerid] = 0; IsInCreate[playerid] = 0; return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[128], tmp[128], idx; cmd = strtok(cmdtext, idx); if(strcmp("/create", cmd, true) == 0 || strcmp("/creer", cmd, true) == 0) { if(CanCreate[playerid] == 1) { if(IsInCreate[playerid] == 0) { new TDcontent[256]; TDcontent = strrest(cmdtext, idx); if(!strlen(TDcontent)) return SendClientMessage(playerid, ERROR, "Usage : /creer | /create [Contenu du TextDraw]"); if(ETextDrawData[ActTextDraw][ETimerStatus] == 0) KillTimer(ETextDrawData[ActTextDraw][ETimerID]); ActTextDraw++; ETextDrawData[ActTextDraw][ETextDrawX] = 0.0; ETextDrawData[ActTextDraw][ETextDrawY] = 0.0; ETextDrawData[ActTextDraw][ETextDrawContent] = TDcontent; ETextDrawData[ActTextDraw][ETextDrawColor] = 1; ETextDrawData[ActTextDraw][ETextDrawFont] = 1; ETextDrawData[ActTextDraw][ETextDrawLetterSizeWidth] = 0.5; ETextDrawData[ActTextDraw][ETextDrawLetterSizeHeight] = 1; ETextDrawData[ActTextDraw][ETextDrawSetOutline] = 1.0; ETextDrawData[ActTextDraw][ETextDrawSetShadow] = 1.0; ETextDrawData[ActTextDraw][ETextDrawSetProportional] = 1; ETextDrawData[ActTextDraw][ETimerStatus] = 0; TogglePlayerControllable(playerid, 0); TD = TextDrawCreate(0.0, 0.0, ETextDrawData[ActTextDraw][ETextDrawContent]); ReloadTextDraw(playerid); ETextDrawData[ActTextDraw][ETimerID] = SetTimerEx("GetKeys", 20, true, "i", playerid); ETextDrawData[ActTextDraw][ETimerStatus] = 1; new str[126]; format(str, 126, "Vous avez crйй la TextDraw n°%d et avez йtй immobilisй. Utilisez /unfreeze pour vous dйsimmobiliser.", ActTextDraw); SendClientMessage(playerid, SUCCESS, "**************** InGame TextDraw Editor by Urefeu ****************"); SendClientMessage(playerid, INFO, str); SendClientMessage(playerid, INFO, "> Utilisez les flиches directionnelles de votre clavier pour le dйplacer et /rename [contenu] pour le modifier."); SendClientMessage(playerid, INFO, "> Utilisez /color | /couleur pour choisir la couleur du TextDraw et /police | /style pour choisir sa police."); SendClientMessage(playerid, INFO, "> Utiliser /size | /taille [largeur du caractиre] [hauteur du caractиre]."); SendClientMessage(playerid, INFO, "> Utiliser /outline | /contour [йpaisseur] et /shadow | /ombre [taille]."); SendClientMessage(playerid, INFO, "> Utilisez /proportional | /proportionnel [0 / 1] pour dйsactiver / activer le rapport proportionnel"); SendClientMessage(playerid, SUCCESS, "********************************************************************************"); IsInCreate[playerid] = 1; return 1; } else { return SendClientMessage(playerid, ERROR, "Vous кtes dйjа entrain de crйer une TextDraw."); } } else { return SendClientMessage(playerid, ERROR, "Vous devez кtre spawn pour crйer une Textdraw."); } } if(strcmp("/rename", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { new newTDcontent[256]; newTDcontent = strrest(cmdtext, idx); if(!strlen(newTDcontent)) return SendClientMessage(playerid, ERROR, "Usage : /rename [Contenu du TextDraw]"); ETextDrawData[ActTextDraw][ETextDrawContent] = newTDcontent; ReloadTextDraw(playerid); return 1; } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /rename [Contenu]"); } } if(strcmp("/color", cmd, true) == 0 || strcmp("/couleur", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { ShowPlayerDialog(playerid, 7825, DIALOG_STYLE_LIST, "Polices de texte", "Choisissez le style de texte souhaitй... \n Style lettrines (0) \n Caractиres bвtons gras (1) \n Caractиres batons fins (2) \n Texte courbй gras (3)", "Choisir", "Quitter"); return 1; } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /color"); } } if(strcmp("/police", cmd, true) == 0 || strcmp("/style", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { ShowPlayerDialog(playerid, 7824, DIALOG_STYLE_LIST, "Couleurs", "Choisissez une couleur... \n Noir \n Blanc \n Jaune \n Orange \n Rouge \n Rose \n Violet \n Vert clair \n Vert foncй \n Bleu clair \n Bleu foncй \n Brun", "Choisir", "Quitter"); return 1; } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /police | /style"); } } if(strcmp("/size", cmd, true) == 0 || strcmp("/taille", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ERROR, "Usage : /size | /taille [largeur du caractиre] [hauteur du caractиre]"); ETextDrawData[ActTextDraw][ETextDrawLetterSizeWidth] = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ERROR, "Usage : /size | /taille [largeur du caractиre] [hauteur du caractиre]"); ETextDrawData[ActTextDraw][ETextDrawLetterSizeHeight] = strval(tmp); ReloadTextDraw(playerid); } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /size | /taille"); } } if(strcmp("/outline", cmd, true) == 0 || strcmp("/contour", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ERROR, "Usage : /outline | /contour [йpaisseur du contour]"); ETextDrawData[ActTextDraw][ETextDrawSetOutline] = strval(tmp); ReloadTextDraw(playerid); } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /outline | /contour"); } } if(strcmp("/shadow", cmd, true) == 0 || strcmp("/ombre", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ERROR, "Usage : /shadow | /ombre [taille de l'ombre]"); ETextDrawData[ActTextDraw][ETextDrawSetShadow] = strval(tmp); ReloadTextDraw(playerid); } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /shadow | /ombre"); } } if(strcmp("/proportional", cmd, true) == 0 || strcmp("/proportionnel", cmd, true) == 0) { if(IsInCreate[playerid] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, ERROR, "Usage : /proportional | /proportionnel [0 (dйsactivй) / 1 (activй)]"); if(strval(tmp) != 0 && strval(tmp) != 1) return SendClientMessage(playerid, ERROR, "Usage : /proportional | /proportionnel [0 (dйsactivй) / 1 (activй)]"); ETextDrawData[ActTextDraw][ETextDrawSetProportional] = strval(tmp); ReloadTextDraw(playerid); } else { return SendClientMessage(playerid, ERROR, "Utilisez /creer | /create [Contenu] pour crйer un TextDraw et pouvoir utiliser /proportional | /proportionnel"); } } if(strcmp("/freeze", cmd, true) == 0) { TogglePlayerControllable(playerid, 0); SendClientMessage(playerid, INFO, "Vous avez йtй freeze. Utilisez /unfreeze pour vous dйsimmobiliser."); return 1; } if(strcmp("/unfreeze", cmd, true) == 0) { TogglePlayerControllable(playerid, 1); SendClientMessage(playerid, INFO, "Vous avez йtй unfreeze. Utilisez /freeze pour vous rйimmobiliser."); return 1; } return 0; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 7825) { switch(response) { case 1: ETextDrawData[ActTextDraw][ETextDrawColor] = 0; // Noir case 2: ETextDrawData[ActTextDraw][ETextDrawColor] = 1; // Blanc case 3: ETextDrawData[ActTextDraw][ETextDrawColor] = 2; // Jaune case 4: ETextDrawData[ActTextDraw][ETextDrawColor] = 3; // Orange case 5: ETextDrawData[ActTextDraw][ETextDrawColor] = 4; // Rouge case 6: ETextDrawData[ActTextDraw][ETextDrawColor] = 5; // Rose case 7: ETextDrawData[ActTextDraw][ETextDrawColor] = 6; // Violet case 8: ETextDrawData[ActTextDraw][ETextDrawColor] = 7; // Vert clair case 9: ETextDrawData[ActTextDraw][ETextDrawColor] = 8; // Vert foncй case 10: ETextDrawData[ActTextDraw][ETextDrawColor] = 9; // Bleu clair case 11: ETextDrawData[ActTextDraw][ETextDrawColor] = 10; // Bleu foncй case 12: ETextDrawData[ActTextDraw][ETextDrawColor] = 11; // Brun default: ETextDrawData[ActTextDraw][ETextDrawColor] = 1; // Blanc } ReloadTextDraw(playerid); } else if(dialogid == 7824) { switch(response) { case 1: ETextDrawData[ActTextDraw][ETextDrawFont] = 0; case 2: ETextDrawData[ActTextDraw][ETextDrawFont] = 1; case 3: ETextDrawData[ActTextDraw][ETextDrawFont] = 2; case 4: ETextDrawData[ActTextDraw][ETextDrawFont] = 3; default: ETextDrawData[ActTextDraw][ETextDrawFont] = 0; } ReloadTextDraw(playerid); } return 1; } forward public GetKeys(playerid); public GetKeys(playerid) { new Key, KeyUD, KeyLR; GetPlayerKeys(playerid, Key, KeyUD, KeyLR); new Float:ChangeValue = 0.5; if(KeyUD == -128) { // UP if(ETextDrawData[ActTextDraw][ETextDrawY] != 0) { ETextDrawData[ActTextDraw][ETextDrawY] -= ChangeValue; ReloadTextDraw(playerid); } } else if(KeyUD == 128) { // DOWN ETextDrawData[ActTextDraw][ETextDrawY] += ChangeValue; ReloadTextDraw(playerid); } if(KeyLR == -128) { // LEFT if(ETextDrawData[ActTextDraw][ETextDrawX] != 0) { ETextDrawData[ActTextDraw][ETextDrawX] -= ChangeValue; ReloadTextDraw(playerid); } } else if(KeyLR == 128) { // RIGHT ETextDrawData[ActTextDraw][ETextDrawX] += ChangeValue; ReloadTextDraw(playerid); } return 1; } forward public ReloadTextDraw(playerid); public ReloadTextDraw(playerid) { TextDrawDestroy(TD); TD = TextDrawCreate(ETextDrawData[ActTextDraw][ETextDrawX], ETextDrawData[ActTextDraw][ETextDrawY], ETextDrawData[ActTextDraw][ETextDrawContent]); switch(ETextDrawData[ActTextDraw][ETextDrawColor]) { case 0: TextDrawColor(TD, 0x00000000); case 1: TextDrawColor(TD, 0xFFFFFFFF); case 2: TextDrawColor(TD, 0xFFFF55FF); case 3: TextDrawColor(TD, 0xFE9301FF); case 4: TextDrawColor(TD, 0xFF0000FF); case 5: TextDrawColor(TD, 0xFFA6FFFF); case 6: TextDrawColor(TD, 0xBC38C7FF); case 7: TextDrawColor(TD, 0x48D750FF); case 8: TextDrawColor(TD, 0x569D22FF); case 9: TextDrawColor(TD, 0x89B9EDFF); case 10: TextDrawColor(TD, 0x1F2EE0FF); case 11: TextDrawColor(TD, 0xB06F2DFF); default: TextDrawColor(TD, 0xFFFFFFFF); } TextDrawFont(TD, ETextDrawData[ActTextDraw][ETextDrawFont]); TextDrawLetterSize(TD, ETextDrawData[ActTextDraw][ETextDrawLetterSizeWidth], ETextDrawData[ActTextDraw][ETextDrawLetterSizeHeight]); TextDrawSetOutline(TD, ETextDrawData[ActTextDraw][ETextDrawSetOutline]); TextDrawSetShadow(TD, ETextDrawData[ActTextDraw][ETextDrawSetShadow]); TextDrawSetProportional(TD, ETextDrawData[ActTextDraw][ETextDrawSetProportional]); TextDrawShowForPlayer(playerid, TD); }