Jump to content
  • 0

How to save clothes colors


Question

9 answers to this question

Recommended Posts

  • 2
Posted (edited)
.@charid = getcharid(0);
query_sql( "SELECT `clothes_color` FROM `char` WHERE `char_id` = '"+.@charid+"'",.@clothesc );

now .@clothesc = the color

you can save it to char variables or else where and call it when you want it

if you put the script here it would be easier for us to help :P

Edited by sader1992
  • Upvote 1
  • Like 1
  • 0
Posted (edited)

 

z7j4WYN.gif

The only problem is: if the player changes the color, the variable dont update with the new number. Just after login another time.

Example:

c2c0KIl.gif

 

Can i update the variable in game? Thanks for your help! ;)

Edited by valesti
  • 0
Posted (edited)

the sql update when you login or when you use the script

you just need to make sure that the line called everytime you want to save new value

so i see here in the photo you are using another style and when you back to your style you back to the old color

try that>>

when you talk to the npc he will save the color value first

then he will ask you to change your style ?

ok change your style and when you get back to your old style make the npc restore your color after he gives you your old style back

 

if you put the script it would be easier for us :P

Edited by sader1992
  • 0
Posted
function	script	SaveClothes	{ // Save Clothes Color

.@charid = getcharid(0);
query_sql( "SELECT `clothes_color` FROM `char` WHERE `char_id` = '"+.@charid+"'",.@clothesc );
setlook 7,0; 
setlook LOOK_BODY2,1;

}

function	script	PutClothes	{ // Put Clothes
.@charid = getcharid(0);
query_sql( "SELECT `clothes_color` FROM `char` WHERE `char_id` = '"+.@charid+"'",.@clothesc );
setlook LOOK_BODY2,0;
setlook LOOK_CLOTHES_COLOR,.@clothesc;

}

@sader1992

The function is called when the player equips/removes the item.

SaveClothes = Player equips the item.

PutClothes = Player removes the item.

 

Here the stylist:

https://pastebin.com/f2iqCcR6

  • 0
Posted (edited)
3 minutes ago, sader1992 said:

// Save Clothes Color == the player equip the item ?

// Put Clothes == unequip ?

Yes! 

{ callfunc "SaveClothes"; },{ callfunc "PutClothes"; }

 

And i finded another problem... /sob

If the player left the game using the equip, when he login the color is 0 again.

Edited by valesti
  • 0
Posted (edited)
function	script	SaveClothes	{ // Save Clothes Color

.@charid = getcharid(0);
query_sql( "SELECT `clothes_color` FROM `char` WHERE `char_id` = '"+.@charid+"'",clothesc );
setlook 7,0; 
setlook LOOK_BODY2,1;

}

function	script	PutClothes	{ // Put Clothes
setlook LOOK_BODY2,0;
setlook LOOK_CLOTHES_COLOR,clothesc;

}

 

Edited by sader1992
  • 0
Posted
query_sql( "SELECT `clothes_color` FROM `char` WHERE `char_id` = '"+.@charid+"'",clothesc );

this line save the value of the color in a char variable (clothesc)

this mean that if the color value 5 clothesc will also be 5

and now you can call clothesc without sql cuz it's a variable by just typing it

so if after you call the func SaveClothes

and the cloth color was 23

if you but npc say 

mes clothesc;

the npc will say 23

and in the unequip you are setting the color to clothesc value so it will be 23

if you call the sql line in equip again in unequip that what will happen

you are setting clothesc to the color value (let's say 23) when equip then the style change and the color for the new style will be 0 and when unequip the sql will be called again and will save clothesc color as 0 from the new style and remove the old value from it and you will end up with the color 0 after unequip

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...