Author Topic: Setting Variables  (Read 657 times)

Code: [Select]
function serverCmdNew(%client){
%client.level = 1;
%client.gold = 25;
messageall('',"\c6 %client.name has began a new charactor!");
messageclient(%client,"","\c6You have a new charactor! You have \c4 %client.gold \c6 Gold and your level is \c4 %client.level\c6!");

Why doesn't this work?

Yes this is part of my MRPG
Thanks for the help on the messageclient problem
Don't expect the Rpg anytime soon.


BTW, you can explain why its doesn't work but I perfer to study other scripts.

« Last Edit: February 20, 2009, 01:12:39 PM by Choneis »

Give me crap for double post but.

This is rather important to my script.

funtion serverCmdNew(%client %level %gold){
function is spelled wrong, and you need commas. (%client, %level, %gold)

   %client.level = 1{
   %client.gold = 25{
Should be "%client.level = 1;"

      messageall('''',''\c6 %client has began a new charactor!");
      messageclient(%client,"","\c6You have a new charactor! You have \c4 %client.gold \6 Gold and your level is \c4 %client.level\c6!");
messageAll('',"message");
That's two single quotes in the first part
Also you'd want to use %client.name, not %client

Again, two single quotes on the messageClient
\6 Gold should be \c6 gold

Why do you have a %level variable if you're not using it in your script? Right now there'd be no difference between typing /new 1 25 and /new 60 1000.

Lastly you only need one }.

Code: [Select]
function serverCmdNew(%client){
%client.level = 1;
%client.gold = 25;
messageall('',"\c6 %client.name has began a new charactor!");
messageclient(%client,"","\c6You have a new charactor! You have \c4 %client.gold \c6 Gold and your level is \c4 %client.level\c6!");

Still not working.

But thanks for the help falcon.

And yes, I hate this dammin more then you.

While I'm at it, these don't work as well.

Code: [Select]
function serverCmdCheckLevel(%client %level){
messageclient(%client,"","\c6 You are level \c2%client.level.'')
}

Code: [Select]
//Leveling System (In progress)
//Max level = 4
{
if %client.level == 1;
{
if %client.xp == 10
%client.level ++ 1
messageclient(%client,"","\c6 You are now level 2!");
%client.ap ++ 5
}
else if %client.level == 2
{
if %client.xp == 25
%client.level ++ 1
messageclient(%client,"","\c6 You are now level 3!");
%client.ap ++ 6
}
else if %client.level == 3
{
if %client.xp == 50
%client.level ++ 1
messageclient(%client,"","\c6 You are now level 4!");
%client.ap ++ 7
}
}
Code: [Select]
//Small cheat for testing

function servercmdcheat(%client %ap)
{
%client.xp ++ 10
}

Have fun while solving my problems XD.
« Last Edit: February 20, 2009, 02:12:56 PM by Choneis »

Code: [Select]
function serverCmdNew(%client){
%client.level = 1;
%client.gold = 25;
messageall('',"\c6 %client.name has began a new charactor!");
messageclient(%client,"","\c6You have a new charactor! You have \c4 %client.gold \c6 Gold and your level is \c4 %client.level\c6!");
Whoops I forgot something

You can't put variables inside quotes so you have to end it, put a spacer, put your variable, put another spacer, and restart your quote.

messageAll('',"\c6" @ %client.name SPC "has begun a new character!");
messageClient(%client,'',\c6You have a new character! You have\c4" SPC %client.gold SPC "\c6gold and your level is\c4" SPC %client.level);

I'm not going to look at the other ones a lot but I see one problem.

serverCmdCheckLevel(%client, %level){
Make sure the commas are between the variables.

Code: [Select]
function serverCmdNew(%client)
{
%client.level = 1;
%client.gold = 25;
        //Should messageallexceptclient
messageall('','\c6%1 has began a new character!',%client.name);
messageclient(%client,"",'\c6You have a new character! You have \c4%1\c6 gold and your level is \c4 %2\c6!',%client.gold,%client.level);
}
when using most message functions, if you put %1 %2 etc in ' ' tags it will display the value of arguements you give after in the message, example: messageClient(%client,'','Your name is %2',%client.wut,%client.name); will display the clients name.