Author Topic: Client Variables  (Read 908 times)

How can i set up a sub-variable under a client? Kinda like this:

%client < normal client variable

%client.cash < client's cash?

Code: [Select]
%client.cash = 0;
if(%client.cash == 0)
   messageClient(%client, '', "Lol, you poor bastard");
else if(%client.cash > 0)
   messageClient(%client, '', "Wait, where'd you get that money?");
else
   messageClient(%client, '', "You owe me some money.");

k thanks. What if it was used in a function. Would you have to call it?

Code: [Select]
function ServerCmdcommand(%client,%client.cash) {

k thanks. What if it was used in a function. Would you have to call it?

Code: [Select]
function ServerCmdcommand(%client,%client.cash) {

Code: [Select]
function serverCmdannounceMoney(%client) {
   if(%client.isAdmin) {
      chatMessageAll(%client, '', "\c6%1 has $%2!", %client.getPlayerName(), %client.cash);
   }
}

k thanks. What if it was used in a function. Would you have to call it?

Code: [Select]
function ServerCmdcommand(%client,%client.cash) {

something like this:
Code: [Select]
function serverCmdSetCash(%client, %someValue)
  {
   %client.cash = %someValue
  }

-- However --
creating a server cmd that lets clients set something like that is a BAD IDEA because they can easily hack in any amount of $$ they want:
~  (opens console)
commandToServer('setCash', 999999999999999999999999);
~ (close console)
*gloat*

your better off just using: %client.cash = <stuff>  inside your script

so if i change the name for the cash variable to like "cats" then they wouldn't know what variable to set it as right?

so if i change the name for the cash variable to like "cats" then they wouldn't know what variable to set it as right?
People would still find that out if they want.

function serverCmdsetCash(%client, %n) {
   if(%client.isAdmin && %n !$= mFloatLength(%n, 0) && %n <= 0) {
      %client.cash += mFloatLength(%n, 2);
      chatMessageAll(%client, '', "\c6%1 gained $%2 ($%3)!", %client.getPlayerName(), mFloatLength(%n, 2), %client.cash);
   }
}


I didn't realize until just now that I forgot about scripts for checking if it's just numbers and how to add to a variable a specific amount simply... Argh...
« Last Edit: June 06, 2011, 05:10:10 PM by MegaScientifical »

function serverCmdsetCash(%client, %n) {
   if(%client.isAdmin && %n !$= mFloatLength(%n, 0) && %n <= 0) {
      %client.cash = +%n;
   }
}


I didn't realize until just now that I forgot about scripts for checking if it's just numbers and how to add to a variable a specific amount simply... Argh...
Instead of "%client.cash = +%n;" isn't it better to do: "%client.cash += %n;"?

Instead of "%client.cash = +%n;" isn't it better to do: "%client.cash += %n;"?

THAT'S it. I was trying to remember how to do that, and was thinking "forget, did I really forget so much?" Thank you, that's what I wanted. That's why I made my stuff tiny. I'll edit it just in case, though. Again, thank you.

Still need to remember the simplest way to check if a string has more than just numbers in it. Someone remind us? I have my old crap method in there, couldn't find the good method someone told me once in my code...
« Last Edit: June 06, 2011, 05:10:54 PM by MegaScientifical »

THAT'S it. I was trying to remember how to do that, and was thinking "forget, did I really forget so much?" Thank you, that's what I wanted. That's why I made my stuff tiny. I'll edit it just in case, though. Again, thank you.

Still need to remember the simplest way to check if a string has more than just numbers in it. Someone remind us? I have my old crap method in there, couldn't find the good method someone told me once in my code...
Hmm it was nothing big. :P
I use it like always when i have to prgram for school.

Now to the easy way to check if it is a number....
I'm gonna search for that.

umm why doesn't this work???

Code: [Select]
function serverCmdsetCash(%client, %n) {
   if(%client.isAdmin && %n !$= mFloatLength(%n, 0) && %n <= 0) {
      %client.cash += %n;
  commandToClient(%client, 'centerPrint', "You currently have $" @ %client.cash,3);
   }
}

umm why doesn't this work???

Code: [Select]
function serverCmdsetCash(%client, %n) {
   if(%client.isAdmin && %n !$= mFloatLength(%n, 0) && %n <= 0) {
      %client.cash += %n;
  commandToClient(%client, 'centerPrint', "You currently have $" @ %client.cash,3);
   }
}
commandToClient when you are allready in the client?
centerPrint("You currently have $" @ %client.cash,3);
Should do the trick i suppose. :P

commandToClient when you are allready in the client?
centerPrint("You currently have $" @ %client.cash,3);
Should do the trick i suppose. :P
nope :/ didn't give any result

this is wat this function looks like now
Code: [Select]
function serverCmdsetCash(%client, %n) {
   if(%client.isAdmin && %n !$= mFloatLength(%n, 0) && %n <= 0) {
      %client.cash += %n;
  centerPrint("You currently have $" @ %client.cash,3);
   }
}

nope :/ didn't give any result

this is wat this function looks like now
Code: [Select]
function serverCmdsetCash(%client, %n) {
   if(%client.isAdmin && %n !$= mFloatLength(%n, 0) && %n <= 0) {
      %client.cash += %n;
  centerPrint("You currently have $" @ %client.cash,3);
   }
}
Does the console give any error?
Otherwise, place an echo to find out where it goes wrong.
echo("Hello i am an echo lol");