Help with a script !

if (created) { Setstring this.string,10; } If (this.string== 10) { DOSTUFF }
Why the IF this.string == 'does not work?

if (strequals(this.string,10))

Thanks!
Is there a command for
IF string DOES NOT exist yet THEN DoStuff?

I’m a terrible scripter, but I think you put an exclamation mark in front.

eg:
if !(strequals(this.string,10))

@dylan i don’t mean that.
I am working on a Characterslot script and i wanna make it so, that it says “Characterslot 1 No look found”
You know what i mean?

___Merged doublepost__________________

EDIT:
@Spoon
I’ve tried it now but didn’t work mh :confused:

___Merged doublepost__________________

EDIT:
Found it out but how to build in the “OR” Command there? because || does not work:

if (strequals(#s(this.string),1)) { DoStuff } //How to make it like this :? if (strequals(#s(this.string),1 || 2 || 3)) {

[QUOTE=Raman;113649]
Thanks!
Is there a command for
IF string DOES NOT exist yet THEN DoStuff?
[/QUOTE]

I’m pretty sure that’s not logical. What do you need this for? I’m sure there’s a way around it.
btw Dylan’s argument (!strequals) would be like saying “if the string does not equal X, continue” as opposed to the “if the string does not exist, continue”

[QUOTE=Raman;113653]
//How to make it like this :?
if (strequals(#s(this.string),1 || 2 || 3))
[/QUOTE]

Wouldn’t it be…

if(strequals(#s(this.string),1) || strequals(#s(this.string),2) || strequals(#s(this.string),3)){ do shit; }
?
Seems really messy though

[CODE]// Charslot Script saving
if (playerchats && startswith(/sslot,#c)) {
tokenize #c;
setstring this.var,#t(1);
if(strequals(#s(this.var),1) || strequals(#s(this.var),2) || strequals(#s(this.var),3)){
setstring this.skincolor#s(this.var),#C0;
setstring this.coatcolor#s(this.var),#C1;
setstring this.sleevescolor#s(this.var),#C2;
setstring this.shoescolor#s(this.var),#C3;
setstring this.beltcolor#s(this.var),#C4;
setstring this.head#s(this.var),#3;
setstring this.sword#s(this.var),#1;
setstring this.shield#s(this.var),#2;
setplayerprop #c,Look saved for Slot #s(this.var);
}
}
// Charslot Script loading
if (playerchats && startswith(/lslot,#c)) {
tokenize #c;
setstring this.var,#t(1);
if(strequals(#s(this.var),1) || strequals(#s(this.var),2) || strequals(#s(this.var),3)){
setplayerprop #C0,#s(this.skincolor#s(this.var));
setplayerprop #C1,#s(this.coatcolor#s(this.var));
setplayerprop #C2,#s(this.sleevescolor#s(this.var));
setplayerprop #C3,#s(this.shoesolor#s(this.var));
setplayerprop #C4,#s(this.beltcolor#s(this.var));
setplayerprop #3,#s(this.head#s(this.var));
setplayerprop #1,#s(this.sword#s(this.var));
setplayerprop #2,#s(this.shield#s(this.var));
setplayerprop #c, Look changed for Slot #s(this.var);
}
}

// help system
if (playerchats && strequals(#c,/help)) {
setplayerprop #c,;
say2 /sslot 1 / 2 / 3 to save a Slot!#b/lslot 1 / 2 /3 to load a Slot!;
}[/CODE]
This is a script which allows you to save ur looks and use them.
Because I was working on that script. IF Charslot DOES NOT exist yet THEN error

[QUOTE=Raman;113657]

[CODE]// Charslot Script saving
if (playerchats && startswith(/sslot,#c)) {
tokenize #c;
setstring this.var,#t(1);
if(strequals(#s(this.var),1) || strequals(#s(this.var),2) || strequals(#s(this.var),3)){
setstring this.skincolor#s(this.var),#C0;
setstring this.coatcolor#s(this.var),#C1;
setstring this.sleevescolor#s(this.var),#C2;
setstring this.shoescolor#s(this.var),#C3;
setstring this.beltcolor#s(this.var),#C4;
setstring this.head#s(this.var),#3;
setstring this.sword#s(this.var),#1;
setstring this.shield#s(this.var),#2;
setplayerprop #c,Look saved for Slot #s(this.var);
}
}
// Charslot Script loading
if (playerchats && startswith(/lslot,#c)) {
tokenize #c;
setstring this.var,#t(1);
if(strequals(#s(this.var),1) || strequals(#s(this.var),2) || strequals(#s(this.var),3)){
setplayerprop #C0,#s(this.skincolor#s(this.var));
setplayerprop #C1,#s(this.coatcolor#s(this.var));
setplayerprop #C2,#s(this.sleevescolor#s(this.var));
setplayerprop #C3,#s(this.shoesolor#s(this.var));
setplayerprop #C4,#s(this.beltcolor#s(this.var));
setplayerprop #3,#s(this.head#s(this.var));
setplayerprop #1,#s(this.sword#s(this.var));
setplayerprop #2,#s(this.shield#s(this.var));
setplayerprop #c, Look changed for Slot #s(this.var);
}
}

// help system
if (playerchats && strequals(#c,/help)) {
setplayerprop #c,;
say2 /sslot 1 / 2 / 3 to save a Slot!#b/lslot 1 / 2 /3 to load a Slot!;
}[/CODE]
This is a script which allows you to save ur looks and use them.
Because I was working on that script. IF Charslot DOES NOT exist yet THEN error
[/QUOTE]

You can check if a string doesn’t exist by simply checking for the ‘empty string’. Example

if ( strequals(#s(this.example),))message this.example does not exist.

Also you can reduce the amount of code with your if statement by doing

if ( strtofloat(#s(this.var)) in |1,3| )

In place of

if(strequals(#s(this.var),1) || strequals(#s(this.var),2) || strequals(#s(this.var),3))

The in keyword can be applied to a range like so i.e. |1,3| => 1 to 3 or an array.

Thanks man :smiley: i was searching for this @tricxta