Author Topic: Wrench GUI push & Brick Height Detection  (Read 1572 times)

As far as variables, I take it? I looked, and they used stuff like
Code: [Select]
(CityRPData.getData(%client.bl_id).valueJailDatabut I figured that had to do with the saving system. At least, the getData part. Or could I do something like
Code: [Select]
(%client.bl_id).cash++;to increment the player's cash? If so, what is the 'variable'? The whole (%client.bl_id).cash? Or can I just use %cash? I really would like a better understanding of variables, currently all I know about em' can be summed up in, oh, say, 3 sentences.

You could create your own variable like say %client.munny.

Kay, but because it's a local variable, would it only be able to be used in it's function? Or could I use it anywhere?

I'm pretty sure you can use it anywhere since it's stored on the client.

Allright, that's what I thought, thanks. Now, how about detecting the height of a brick? Also, forcing last wrench GUI clientside?

Edit: Here's what I have so far, but it's full of glitches. I need some help with color codes and displaying variables. Anything else that looks messed up would be nice to point out also.

function serverCmdGiveBlocks(%client, %victim, %amount)
{
   if(%client.Blocks<=0)
   {
      messageClient(%client,"","\c0You do not have any blocks!");
   }
   else
   {
      if(%client.Blocks<=%amount)
      {
         messageClient(%client,"","\c0You do not have that many blocks!");
      }
      else
      {
         %victim=findclientbyname(%victim);
         if(!isObject(%victim))
         {
            messageClient(%client,"","\c0That player does not exist.");

         }
         else
         {
            %client.Blocks-=%amount;
            %victim.Blocks+=%amount;
            messageClient(%victim,"","\c0You have recieved %amount from %client.name.");
            messageClient(%client,"","\c0You have given %amount to %victim.name.");
         }
      }
   }
}

function serverCmdTestAll(%client)
{
   messageClient(%client,"","Name getting test: your name is %client.name");
   messageClient(%client,"","Text color test: This word white is \c0white.");
   messageClient(%client,"","Variables test: I have added 10 blocks, use blocks command");
   %client.blocks+=10;
}

function serverCmdBlocks(%client)
{
   messageClient(%client,"","/c0You have %client.blocks blocks!");
}
« Last Edit: May 23, 2009, 11:45:51 PM by cucumberdude »

What is the point in people like you posting in Coding Help if you don't know anything about Coding? It just confuses people ... its absurd.
Not to get on your bad side Ephi, but this is just to clear myself up. I was simply pointing out that it looked odd, and clarifying it so I may learn also. I am fairly sure I haven't posted any helping posts in this section, due to my lack of knowledge in coding. I am just a beginner and wanted to make sure it was right, so I may learn correctly.

Well, for the Wrench GUI thing, I think I have something similar to that. A long time ago, Darklight hosted a CityRP server, and he gave us a pack of GUI's that we needed for his server. In this pack he included an edit to the wrench GUI where there was a button at the bottom saying Quick Event. This button sends your events, without you editing them, so it just sends the last events you sent on a brick. If that is what you mean by push the last Wrench GUI, I can trim the city RP stuff off and give you the edit.
Code: [Select]
function serverCmdTestAll(%client)
{
messageClient(%client,"","Name getting test: your name is %client.name");
messageClient(%client,"","Text color test: This word white is \c0white.");
messageClient(%client,"","Variables test: I have added 10 blocks, use blocks command");
%client.blocks+=10;
}
There is alot wrong with that, for example, if you want it to say a variable in a message string, you need to do something like this:

messageClient(%client, "","Name getting test: Your name is"@ %client.name);
« Last Edit: May 24, 2009, 10:40:45 AM by AGlass0fMilk »

You should do %amount = mFloor(%amount) at the top of the function otherwise people can enter huge floating point numbers to get #INF blocks. Your logic also states that if the client's blocks is less than or equal to the amount he's trying to give, it says he doesn't have enough. It should only be less than, or he can't give all his money to someone.
« Last Edit: May 24, 2009, 11:01:35 AM by Ephialtes »

Whoops. Fixing dat.
Edit: if I have a sentence, such as "You have %amount bricks", do I do "You have" @ %amount "bricks"?
« Last Edit: May 24, 2009, 02:13:59 PM by cucumberdude »

Yes But you would do another @ symbol after the variable. So mid-sentence is:

messageclient(%client, "","\c6Hi, your name is"@ %client.name @"! Let's be friends :D");

and at the end of a sentence it would be:

messageclient(%client, "","\c6Hi, your name is"@ %client.name);

So you can pretty much put as many series of "s as you want in the messageClient(%client,"","stuffs"); part of the message?
Got it.

You could create your own variable like say %client.munny.

munny?

On brick height:

The elevation of a brick's center is given by: getWord(%brick.getTransform(), 2)
To get the elevation of the brick's top or bottom, take the center and add or subtract: (%brick.getDatablock().brickSizeZ * 0.1)
To get the physical height of a brick itself (that is, top elevation minus bottom elevation), use: (%brick.getDatablock().brickSizeZ * 0.2)

You need to multiply because BrickSizeZ is the height in plate thicknesses meaning 1/3 of a standard brick height. A plate thickness is actually 0.2 world units.