GTAOnline.net

San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: DrEnzo; le 02 Octobre 2011, 15:36:40

Titre: Mettre 3 variables dans un ShowPlayerDialog..
Posté par: DrEnzo; le 02 Octobre 2011, 15:36:40
Re Bonjour pour se qui mon deja vu ;)

Je recherche comment mettre une variable dans mon code.
Bon, oké je sais le faire, mes sa ne marche pas :P

Donc j'ai besoin de votre aide.. :

ERREURS :

C:\Users\Alv4rd\Desktop\MON SERVEUR GTA\gamemodes\gm.pwn(122) : error 006: must be assigned to an array
C:\Users\Alv4rd\Desktop\MON SERVEUR GTA\gamemodes\gm.pwn(127) : error 006: must be assigned to an array
C:\Users\Alv4rd\Desktop\MON SERVEUR GTA\gamemodes\gm.pwn(130) : warning 202: number of arguments does not match definition
C:\Users\Alv4rd\Desktop\MON SERVEUR GTA\gamemodes\gm.pwn(130) : warning 202: number of arguments does not match definition
C:\Users\Alv4rd\Desktop\MON SERVEUR GTA\gamemodes\gm.pwn(130) : warning 202: number of arguments does not match definition
C:\Users\Alv4rd\Desktop\MON SERVEUR GTA\gamemodes\gm.pwn(127) : warning 204: symbol is assigned a value that is never used: "namearme1"

Code : http://pastebin.com/1J89CBGm (http://pastebin.com/1J89CBGm)

Merci de votre aide :-)
Titre: Re : Mettre 3 variables dans un ShowPlayerDialog..
Posté par: Xartrick le 02 Octobre 2011, 15:41:26
Pour pouvoir donner en argument une chaîne de caractères comme tu veux faire, il faut d'abord la formater.
Tu ne peux pas formater une chaîne de caractères comme ceci !
Tu dois obligatoirement faire comme cela ...


new sString[128],
    iInteger = 1337;

format(sString, sizeof(sString), "Je suis une chaîne de caractère formaté, la preuve: %d !", iInteger);

SendClientMessageToAll(0xFFFFFFFF, sString);
Titre: Re : Re : Mettre 3 variables dans un ShowPlayerDialog..
Posté par: DrEnzo; le 02 Octobre 2011, 15:54:43
Pour pouvoir donner en argument une chaîne de caractères comme tu veux faire, il faut d'abord la formater.
Tu ne peux pas formater une chaîne de caractères comme ceci !
Tu dois obligatoirement faire comme cela ...


new sString[128],
    iInteger = 1337;

format(sString, sizeof(sString), "Je suis une chaîne de caractère formaté, la preuve: %d !", iInteger);

SendClientMessageToAll(0xFFFFFFFF, sString);
C'est exactement ce que je cherché ! La chaine formaté ! Merci !!

Parcontre, je n'est pas trouvé comment mêttre des variables dans ce code :

ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Sac","[Slot 1][Mettre] JE VOUDRAIS METTRE MA VARIABLE ICI\r\n","Prendre", "Fermer");

Merci :-)
Titre: Re : Mettre 3 variables dans un ShowPlayerDialog..
Posté par: Xolokos le 02 Octobre 2011, 22:04:22
http://pastebin.gtaonline.fr/pastebin.php?show=1127 (http://pastebin.gtaonline.fr/pastebin.php?show=1127)

Je crois que je les fait dedans en bref tu met sString dans l'exemple a Xartrick tu met celà a la place de ton texte.


Code: (pawn) [Sélectionner]
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Sac","[Slot 1][Mettre] JE VOUDRAIS METTRE MA VARIABLE ICI\r\n","Prendre", "Fermer");
Et tu met t'as chaine sString  que tu as formaté dedans en bref :

Code: (pawn) [Sélectionner]
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Sac",sString ,"Prendre", "Fermer");
Et voilà.
Titre: Re : Re : Mettre 3 variables dans un ShowPlayerDialog..
Posté par: DrEnzo; le 03 Octobre 2011, 17:44:59
http://pastebin.gtaonline.fr/pastebin.php?show=1127 (http://pastebin.gtaonline.fr/pastebin.php?show=1127)

Je crois que je les fait dedans en bref tu met sString dans l'exemple a Xartrick tu met celà a la place de ton texte.


Code: (pawn) [Sélectionner]
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Sac","[Slot 1][Mettre] JE VOUDRAIS METTRE MA VARIABLE ICI\r\n","Prendre", "Fermer");
Et tu met t'as chaine sString  que tu as formaté dedans en bref :

Code: (pawn) [Sélectionner]
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Sac",sString ,"Prendre", "Fermer");
Et voilà.


D'accord. C'est exactement cas. Parcontre, j'ai un autre soucie avec mon code.

Il est sensé affiché si le joueur n'a pas d'arme :

[SLOT 1][Mettre] Arme
[SLOT 2][Mettre] Arme
[SLOT 3][Mettre] Arme
[SLOT 4][Mettre] Arme
[SLOT 5][Mettre] Arme

Seulement, il n'affiche pas le SLOT 1

Je ne comprend pas.. Merci de votre aide ;)

-> http://pastebin.com/fS5V097x (http://pastebin.com/fS5V097x)
Titre: Re : Mettre 3 variables dans un ShowPlayerDialog..
Posté par: Xartrick le 04 Octobre 2011, 18:53:15
Lignes 59 à 60 ...

format(messagefinal, sizeof(messagefinal), "", emplacement1, emplacement2, emplacement3, emplacement4, emplacement5);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Sac", "[Slot 2][Mettre] Arme\r\n[Slot 3][Mettre] Arme\r\n[Slot 4][Mettre] Arme\r\n[Slot 5][Mettre] Arme\r\n", "Prendre", "Fermer");

Tu veux formater ta variable mais tu ne la formate pas correctement (tu n'utilise aucun formateur), voici le résultat de ton code (s'il ne te génère aucune erreur) ...


Mais il n'y a rien ?! Et oui, justement !

format(messagefinal, sizeof(messagefinal), "%s\r\n%s\r\n%s\r\n%s\r\n%s\r\n", emplacement1, emplacement2, emplacement3, emplacement4, emplacement5);
Maintenant, la chaîne de caractère est bien formaté, mais il reste encore un problème, tu n'utilise pas cette chaîne !

ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Sac", "[Slot 2][Mettre] Arme\r\n[Slot 3][Mettre] Arme\r\n[Slot 4][Mettre] Arme\r\n[Slot 5][Mettre] Arme\r\n", "Prendre", "Fermer");
Un peu inutile si tu ne l'utilise pas ...

ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Sac", messagefinal, "Prendre", "Fermer");
Terminé !