Aller au contenu
  • 0

HDV/HDE - Vendre l'objet


Question

Posté(e)

Salut !

J'en viens à votre aide chers Skripteurs (plutôt les bons :p) pour un Skript, assez gros projet, qui me prend du temps et je bloque donc c'est énervant :/

Je fais donc un "Hôtel des échanges" un peu dans le même principe que les "Hôtel des ventes".

Je dois afficher tous les items en vente dans un GUI et lorsque l'on clique cela vend, pour le vente je l'ai fait dans une fonction avec un ID par vente, tout cela stocké dans une BDD.

Le problème c'est que pour afficher les offres j'utilise une boucle avec un "count" mais pour le "to close the run [le count]" le count n'est plus valable car la boucle est terminée, c'est à dire que le count = à la fin.

C'est dur à comprendre donc si vous avez besoin de précisions n'hésitez pas ;)

 

(Le problème est dans les "format slot the run" et dans la fonction "changeIt")

function changeIt(changer : player, id : text):
   set {_id} to {_id} parsed as integer
   send "%{_id}%" to {_changer}
   set {_itemP} to the first element out of objects in column "echange_item" from result of query "SELECT echange_item FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_numbV} to the first element out of objects in column "item_nombre" from result of query "SELECT item_nombre FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_itemV} to the first element out of objects in column "item_vente" from result of query "SELECT item_vente FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_numbP} to the first element out of objects in column "echange_nombre" from result of query "SELECT echange_nombre FROM offres_hde WHERE id = '%{_id}%'" and close
   send "%{_itemP}% %{_numbV}% %{_itemV}% %{_numbP}%" to {_changer}
   if number of {_itemP} in {_changer}'s inventory < {_numbP}:
       set {_msgAnnul} to {@NoSuffItems}
       replace all "[prix]" in {_msgAnnul} with "%{_itemIdP}%"
       broadcast "bite"
       annuler({_changer}, "%{_msgAnnul}%")
       stop
   remove {_numbP} of {_itemP} from {_changer}'s inventory
   give {_numbV} of {_itemV} to {_changer}
   annuler({_changer}, {@SuccEchange})


command /hde:
   trigger:
       add objects in column "id" from result of query "SELECT id FROM offres_hde LIMIT 0,45" and close to {_ID::*}
       add objects in column "pseudo_vendeur" from result of query "SELECT pseudo_vendeur FROM offres_hde LIMIT 0,45" and close to {_vendeur::*}
       add objects in column "item_id" from result of query "SELECT item_id FROM offres_hde LIMIT 0,45" and close to {_idV::*}
       add objects in column "item_nombre" from result of query "SELECT item_nombre FROM offres_hde LIMIT 0,45" and close to {_numbV::*}
       add objects in column "item_name" from result of query "SELECT item_name FROM offres_hde LIMIT 0,45" and close to {_nameV::*}
       add objects in column "item_enchantements" from result of query "SELECT item_enchantements FROM offres_hde LIMIT 0,45" and close to {_enchantV::*}
       add objects in column "echange_id" from result of query "SELECT echange_id FROM offres_hde LIMIT 0,45" and close to {_idP::*}
       add objects in column "echange_nombre" from result of query "SELECT echange_nombre FROM offres_hde LIMIT 0,45" and close to {_numbP::*}
       add objects in column "echange_enchantements" from result of query "SELECT echange_enchantements FROM offres_hde LIMIT 0,45" and close to {_enchantP::*}
       open chest with 6 rows named {@NomMenuHDE} to player
       format slot 48 of player with egg named "&bVendre" to close then run [send {@VendreMenu}]
       format slot 50 of player with stick named "&r%{_nombreOffres}% offres en ventes" to be unstealable
       format slot 53 of player with 2 arrows named "&rPage &a2" to be unstealable
       set {_count} to 0
       set {_count1} to 1
       loop 45 times:
           if {_idV::%{_count1}%} is not set:
               stop
           set {_item} to "%{_idV::%{_count1}%}%" parsed as item
           set {_itemP} to "%{_idP::%{_count1}%}%" parsed as item
           if {_enchantP::%{_count1}%} is "NULL":
               set {_enchantsP} to ""
           else:
               replace all "/" in {_enchantP::%{_count1}%} with "||&7"
               set {_enchantsP} to "||&7echanté(e)(s)||&7%{_enchantP::%{_count1}%}%"
           if {_nameV::%{_count1}%} is "NULL":
               if {_enchantV::%{_count1}%} is "NULL":
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} with lore "||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, {_ID::%{_count1}%})]
               else:
                   replace all "/" in {_enchantV::%{_count1}%} with "||&7"
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} with lore "&7%{_enchantV::%{_count1}%}%||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, {_ID::%{_count1}%})]
           else:
               if {_enchantV::%{_count1}%} is "NULL":
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} named "&b&o%{_nameV::%{_count1}%}%" with lore "||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, {_ID::%{_count1}%})]
               else:
                   replace all "/" in {_enchantV::%{_count1}%} with "||&7"
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} named "&b&o%{_nameV::%{_count1}%}%" with lore "&7%{_enchantV::%{_count1}%}%||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, {_ID::%{_count1}%})]
           add 1 to {_count}
           add 1 to {_count1}

23 réponses à cette question

Messages recommandés

  • 0
Posté(e)
Look ça tu devrais comprendre de quoi je parle.

Je sais pas donne moi un exemple, je ne vois de quoi tu parles. :/

Tu veux dire que je devrais utiliser un "on click" ?

Je viens de me dire que je pourrais mettre l'ID dans le nom avec "#ID LeNom"

Sinon récupérer le nom, impossible car les objets peuvent avoir le même nom, j'ai regardé pou récupérer le slot mais c'est bug.

Mon skript je l'aimerais en 1.7, donc Umbaska impossible. :/

Merci de ton aide :D

  • 0
Posté(e)
Pourrais tu me poster l'erreur stp?

Il n'y a bien sur pas d'erreur, le problème c'est que je ne sais pas comment faire car la variable {_count} est terminée lorsque le click to run s'active ;)

  • 0
Posté(e)

Ajoutes toutes les valeurs de tes {_count1} dans une liste {_list::*}, par la suite tu fais que lorsque le joueur clique sur un item qui est ex le 4e item du menu, tu prends la 4e valeur de ta liste et le set dans une certaine variable que tu mets ensuite à la place de ton %{_count1}% dans click to run

 

Si je n'ai pas été clair, dis le moi je vais te faire un exemple

  • 0
Posté(e)
Ajoutes toutes les valeurs de tes {_count1} dans une liste {_list::*}, par la suite tu fais que lorsque le joueur clique sur un item qui est ex le 4e item du menu, tu prends la 4e valeur de ta liste et le set dans une certaine variable que tu mets ensuite à la place de ton %{_count1}% dans click to run

Haha pas mal :')

Et comment je fais pour savoir si c'est le 4e du menu ! :D

Merci de m'aider <3

  • 0
Posté(e)

function changeIt(changer : player, id : text):
   if {list::*} is set:
       set {_loop} to {_id} parsed as an integer
       loop {list::*}:
           if loop-number is {_loop}:
               set {_id} to loop-value
              delete {list::*}
               exit loop
   else:
       set {_id} to {_id} parsed as integer
   send "%{_id}%" to {_changer}
   set {_itemP} to the first element out of objects in column "echange_item" from result of query "SELECT echange_item FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_numbV} to the first element out of objects in column "item_nombre" from result of query "SELECT item_nombre FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_itemV} to the first element out of objects in column "item_vente" from result of query "SELECT item_vente FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_numbP} to the first element out of objects in column "echange_nombre" from result of query "SELECT echange_nombre FROM offres_hde WHERE id = '%{_id}%'" and close
   send "%{_itemP}% %{_numbV}% %{_itemV}% %{_numbP}%" to {_changer}
   if number of {_itemP} in {_changer}'s inventory < {_numbP}:
       set {_msgAnnul} to {@NoSuffItems}
       replace all "[prix]" in {_msgAnnul} with "%{_itemIdP}%"
       broadcast "bite"
       annuler({_changer}, "%{_msgAnnul}%")
       stop
   remove {_numbP} of {_itemP} from {_changer}'s inventory
   give {_numbV} of {_itemV} to {_changer}
   annuler({_changer}, {@SuccEchange})


command /hde:
   trigger:
       add objects in column "id" from result of query "SELECT id FROM offres_hde LIMIT 0,45" and close to {_ID::*}
       add objects in column "pseudo_vendeur" from result of query "SELECT pseudo_vendeur FROM offres_hde LIMIT 0,45" and close to {_vendeur::*}
       add objects in column "item_id" from result of query "SELECT item_id FROM offres_hde LIMIT 0,45" and close to {_idV::*}
       add objects in column "item_nombre" from result of query "SELECT item_nombre FROM offres_hde LIMIT 0,45" and close to {_numbV::*}
       add objects in column "item_name" from result of query "SELECT item_name FROM offres_hde LIMIT 0,45" and close to {_nameV::*}
       add objects in column "item_enchantements" from result of query "SELECT item_enchantements FROM offres_hde LIMIT 0,45" and close to {_enchantV::*}
       add objects in column "echange_id" from result of query "SELECT echange_id FROM offres_hde LIMIT 0,45" and close to {_idP::*}
       add objects in column "echange_nombre" from result of query "SELECT echange_nombre FROM offres_hde LIMIT 0,45" and close to {_numbP::*}
       add objects in column "echange_enchantements" from result of query "SELECT echange_enchantements FROM offres_hde LIMIT 0,45" and close to {_enchantP::*}
       open chest with 6 rows named {@NomMenuHDE} to player
       format slot 48 of player with egg named "&bVendre" to close then run [send {@VendreMenu}]
       format slot 50 of player with stick named "&r%{_nombreOffres}% offres en ventes" to be unstealable
       format slot 53 of player with 2 arrows named "&rPage &a2" to be unstealable
       set {_count} to 0
       set {_count1} to 1
       loop 45 times:
           if {_idV::%{_count1}%} is not set:
               stop
           add {_count1} to {list::*}
           set {_item} to "%{_idV::%{_count1}%}%" parsed as item
           set {_itemP} to "%{_idP::%{_count1}%}%" parsed as item
           if {_enchantP::%{_count1}%} is "NULL":
               set {_enchantsP} to ""
           else:
               replace all "/" in {_enchantP::%{_count1}%} with "||&7"
               set {_enchantsP} to "||&7echanté(e)(s)||&7%{_enchantP::%{_count1}%}%"
           if {_nameV::%{_count1}%} is "NULL":
               if {_enchantV::%{_count1}%} is "NULL":
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} with lore "||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-number)]
               else:
                   replace all "/" in {_enchantV::%{_count1}%} with "||&7"
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} with lore "&7%{_enchantV::%{_count1}%}%||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-number)]
           else:
               if {_enchantV::%{_count1}%} is "NULL":
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} named "&b&o%{_nameV::%{_count1}%}%" with lore "||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-number)]
               else:
                   replace all "/" in {_enchantV::%{_count1}%} with "||&7"
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} named "&b&o%{_nameV::%{_count1}%}%" with lore "&7%{_enchantV::%{_count1}%}%||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-number)]
           add 1 to {_count}
           add 1 to {_count1}

 

J'ai pas testé mais sa devrais marcher. Donne moi en des nouvelles

  • J'aime 1
  • 0
Posté(e)
J'ai pas testé mais sa devrais marcher. Donne moi en des nouvelles

Nan justement c'est ca le problème xD

Vu que lorsque le mec va cliquer la loop est déjà réalisée ! Donc loop-number ou {_count} est au "maximum", au dernier tour qu'elle réalisée :D

Je sais pas si tu comprends xD

Test tu verras ;)

  • 0
Posté(e)

Non, il me semble que si tu cliques vu qu'il n'est pas stocké sous une variable le loop sera le bon loop

 

J'utilise cette technique dans un de mes skripts et sa fonctionne bien

 

 format slot {_s} of player with {_i} named "<light aqua>%{_n}%" with lore "<yellow>Seller: <gold>%{_seller}%||<yellow>Quantity: <gold>%{_count}%||<yellow>Buy now price: $<gold>%{_p}%||<yellow>Starting bid: $<orange>%{ge::startbid::%loop-value%}%||<yellow>Highest bidder: <orange>%{ge::buyer::%loop-value%}%, <yellow>$<orange>%{ge::currentbid::%loop-value%}%||&4Time left: %{_timeleft}%||%{ge::sep}%||<yellow>Item Lore: ||||<gold>%{_il}%||||%{ge::sep}%||||&8Auction Item" to close then run "sudo %player% gepurchase %loop-value%"

  • 0
Posté(e)

Bon... il est temps de trouver une solution sur mon serveur :/ Je vais faire des tests

 

EDIT: J'ai remplacé le code pour utilier loop-value plutot que loop-number, je ne sais pas si sa va régler le problème, il faudra tester de ton coté vu que ton skript ne semble pas fonctionner sur mon serveur.. oO

 

EDIT: Si cela ne marche pas temps il sera temps d'aller voir les meilleurs parce que je suis à court d'idée sinon @NFell @MostFunGuy @Maeyrl

 

function changeIt(changer : player, id : text):
   if {list::*} is set:
       set {_loop} to {_id} parsed as an integer
       loop {list::*}:
           if loop-number is {_loop}:
               set {_id} to loop-value
              delete {list::*}
               exit loop
   else:
       set {_id} to {_id} parsed as integer
   send "%{_id}%" to {_changer}
   set {_itemP} to the first element out of objects in column "echange_item" from result of query "SELECT echange_item FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_numbV} to the first element out of objects in column "item_nombre" from result of query "SELECT item_nombre FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_itemV} to the first element out of objects in column "item_vente" from result of query "SELECT item_vente FROM offres_hde WHERE id = '%{_id}%'" and close
   set {_numbP} to the first element out of objects in column "echange_nombre" from result of query "SELECT echange_nombre FROM offres_hde WHERE id = '%{_id}%'" and close
   send "%{_itemP}% %{_numbV}% %{_itemV}% %{_numbP}%" to {_changer}
   if number of {_itemP} in {_changer}'s inventory < {_numbP}:
       set {_msgAnnul} to {@NoSuffItems}
       replace all "[prix]" in {_msgAnnul} with "%{_itemIdP}%"
       broadcast "bite"
       annuler({_changer}, "%{_msgAnnul}%")
       stop
   remove {_numbP} of {_itemP} from {_changer}'s inventory
   give {_numbV} of {_itemV} to {_changer}
   annuler({_changer}, {@SuccEchange})


command /hde:
   trigger:
       add objects in column "id" from result of query "SELECT id FROM offres_hde LIMIT 0,45" and close to {_ID::*}
       add objects in column "pseudo_vendeur" from result of query "SELECT pseudo_vendeur FROM offres_hde LIMIT 0,45" and close to {_vendeur::*}
       add objects in column "item_id" from result of query "SELECT item_id FROM offres_hde LIMIT 0,45" and close to {_idV::*}
       add objects in column "item_nombre" from result of query "SELECT item_nombre FROM offres_hde LIMIT 0,45" and close to {_numbV::*}
       add objects in column "item_name" from result of query "SELECT item_name FROM offres_hde LIMIT 0,45" and close to {_nameV::*}
       add objects in column "item_enchantements" from result of query "SELECT item_enchantements FROM offres_hde LIMIT 0,45" and close to {_enchantV::*}
       add objects in column "echange_id" from result of query "SELECT echange_id FROM offres_hde LIMIT 0,45" and close to {_idP::*}
       add objects in column "echange_nombre" from result of query "SELECT echange_nombre FROM offres_hde LIMIT 0,45" and close to {_numbP::*}
       add objects in column "echange_enchantements" from result of query "SELECT echange_enchantements FROM offres_hde LIMIT 0,45" and close to {_enchantP::*}
       open chest with 6 rows named {@NomMenuHDE} to player
       format slot 48 of player with egg named "&bVendre" to close then run [send {@VendreMenu}]
       format slot 50 of player with stick named "&r%{_nombreOffres}% offres en ventes" to be unstealable
       format slot 53 of player with 2 arrows named "&rPage &a2" to be unstealable
       set {_count} to 0
       set {_count1} to 1
loop 45 times:
	add 1 to {_h}
	add {_h} to {_45::*}
       loop {_45::*}:
           if {_idV::%{_count1}%} is not set:
               stop
           add {_count1} to {list::*}
           set {_item} to "%{_idV::%{_count1}%}%" parsed as item
           set {_itemP} to "%{_idP::%{_count1}%}%" parsed as item
           if {_enchantP::%{_count1}%} is "NULL":
               set {_enchantsP} to ""
           else:
               replace all "/" in {_enchantP::%{_count1}%} with "||&7"
               set {_enchantsP} to "||&7echanté(e)(s)||&7%{_enchantP::%{_count1}%}%"
           if {_nameV::%{_count1}%} is "NULL":
               if {_enchantV::%{_count1}%} is "NULL":
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} with lore "||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-value)]
               else:
                   replace all "/" in {_enchantV::%{_count1}%} with "||&7"
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} with lore "&7%{_enchantV::%{_count1}%}%||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-value)]
           else:
               if {_enchantV::%{_count1}%} is "NULL":
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} named "&b&o%{_nameV::%{_count1}%}%" with lore "||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-value)]
               else:
                   replace all "/" in {_enchantV::%{_count1}%} with "||&7"
                   format slot {_count} of player with {_numbV::%{_count1}%} of {_item} named "&b&o%{_nameV::%{_count1}%}%" with lore "&7%{_enchantV::%{_count1}%}%||||&eVendu par: &7%{_vendeur::%{_count1}%}%||&eContre: &7%{_numbP::%{_count1}%}% %{_itemP}%%{_enchantsP}%" to close then run [changeIt(player, loop-value)]
           add 1 to {_count}
           add 1 to {_count1}

  • 0
Posté(e)

Merci quand même et tu vois bien que c'est pas du tout simple xD

En fait mon Skript est bien plus long que cela.

J'ai fait un post sur le forum de Skript mais bon...

Non cela ne marchera pas non plus :3

  • 0
Posté(e)

Pour les curieux voici mon explication plus ou moins clair de la solution!

 

"Si tu n'utilises pas les [] tu peux obtenir la valeur du {_count} lorsque l'objet a été formaté, ce n'est qu'un bug avec les [] qui fait que tu obtiens toujours la valeur finale du {_count}. Si tu fais passer ça sous forme d'une commande tout devrais fonctionner."

×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.