Author Topic: New player list  (Read 3778 times)

I am try create this script code with gui, I am not sure if this right or wrong.

Code: [Select]
function clientCmdInfoListProfile(%status, %name, %BL_ID)
{
        $status = %status;
$name = %name;
$BL_ID = %BL_ID;


InfoList.addRow(InfoList.rowCount(), $status TAB $name TAB $BL_ID);
}

         %status = getField(%player,2);
         if(%status $= 3)
            %status = "<bitmap:add-ons/script_InformationPlayer/icon_hostshield.png>";
         else if(%status $= 2)
            %status = "<bitmap:add-ons/script_InformationPlayer/icon_superadminshield.png>";
         else if(%status $= 1)
            %status = "<bitmap:add-ons/script_InformationPlayer/icon_adminshield.png>";
         else
            %status = "<bitmap:add-ons/script_InformationPlayer/icon_playershield.png>";
      }
   }
function clientCmdInfoListProfile
« Last Edit: February 27, 2011, 05:49:04 PM by Furling »

I'm afraid you'll need to relearn basic TorqueScript semantics before attempting this. I'd point out the multiple syntax errors but I'd be better off just writing the thing myself and showing it to you.

I'm afraid you'll need to relearn basic TorqueScript semantics before attempting this. I'd point out the multiple syntax errors but I'd be better off just writing the thing myself and showing it to you.
good idea. I want icons add it to new player list. I made icons already.

Eh, well, you could always try a hack if you feel crafty. It'd be a bit more complicated, though.


Code: [Select]
package Fancy_Badges
{
function NPL_List::addRow(%this, %row, %text, %index)
{
if(%row == 0)
if(%text $= "A")
%text = "<bitmap:....>";
else if(%text $= "S")
%text = "<bitmap:....>";

return parent::addRow(%this, %row, %text, %index);
}
};
activatePackage(Fancy_Badges);

Or something like that.


* I take no responsibility if this untested code snippet contains syntax errors or outright destroys functionality of the player list and/or your game.

Eh, well, you could always try a hack if you feel crafty. It'd be a bit more complicated, though.


Quote
package Fancy_Badges
{
   function NPL_List::addRow(%this, %row, %text, %index)
   {
      if(%row == 0)
         if(%text $= "A")
            %text = "<bitmap:....>";
         
else if(%text $= "S")
            
%text = "<bitmap:....>";
         
      return parent::addRow(%this, %row, %text, %index);
   }
};
activatePackage(Fancy_Badges);
Bold is causes a syntax error.

Does the player list protection also happen clientside, then?

Bold is causes a syntax error.
Oh boy Kalphiter's here to question my scripting prowess.

I just ran the script and it does not contain syntax errors. Using no curly braces with if/else ifs is perfectly valid and I utilize it often.

Code: [Select]
// Fetches a player's profile (creating it if nessicary).
// @ProfileSO
function GameConnection::getProfile(%client)
{
if(!Profiler.isProfileActive(%client.bl_id))
if(Profiler.isProfile(%client.bl_id))
if(Profiler.loadProfile(%client.bl_id))
return Profiler.getProfile(%client.bl_id);
else
return -2;
else
if(Profiler.createProfile(%client.bl_id))
if(Profiler.loadProfile(%client.bl_id))
return Profiler.getProfile(%client.bl_id);
else
return -2;
else
return -1;
else
return Profiler.getProfile(%client.bl_id);
}

Learn your place. I'll give you a hint if you can't find it: It's under me.

Using no curly braces with if/else ifs is perfectly valid and I utilize it often.
A shorthand if, or any statement, can only have one statement for that block.
This is Torque's fault, such a standard practice ruined.

==> if(false)echo("no");else echo("iban is right");
iban is right


I too use this all the time.

==> if(false)echo("no");else echo("iban is right");
iban is right


I too use this all the time.
That wasn't what he did, though.
He did this:
Code: [Select]
if("namfe" $= "name")
    if(644 == 644)
echo("guy's name is name and blid is 644");
    else
echo("this guy isn't name");
But in theory, it should be executed like this:
Code: [Select]
if("namfe" $= "name")
{
    if(644 == 644)
    {
echo("guy's name is name and blid is 644");
    }
}

else
    echo("this guy isn't name");
« Last Edit: February 27, 2011, 06:16:01 PM by Kalphiter »

==> if(false) %a = 1; else %a = 0;echo(%a);
0


==> if(true) %a = 1; else %a = 0;echo(%a);
1


Works with variable setting too. Yes, I'm testing these in-game.

A shorthand if, or any statement, can only have one statement for that block.
This is Torque's fault, such a standard practice ruined.
Brilliant deduction, Detective Jackass, except that this is one clause.

if()
...if()
......if()
......elseif()
...else if()
......if()
......elseif()

There's no voodoo magic being committed here. The first if activates the second if which can activate a string of ifs and else ifs and elses.

Source: GameMode_ZAPT/functions.cs
Code: [Select]
if(!%mini.zombiesDisabled)
if(zombieGameSetUpRight(%mini) && miniGameCstar fishe(%mini.owner, %this))
if(%mini.getProperty("bots") || %db.zombieAIOnly)
if($sim::time - %this.zombieSpawnTime >= %mini.vehicleRespawnTime / 1000)
if(!%db.zombieSpawnOnce || %mini.zombieTimeAssembled - %this.zombieSpawnTime >= 0)
return true;

If you had taken twelve seconds to plug the code into a script and check it yourself you wouldn't have came off as a) incorrect, b) a know-nothing douchebag.


And it's not unique to TorqueScript. Plug this javascript code into the try-it-yourself editor on the w3schools
http://www.w3schools.com/JS/tryit.asp?filename=tryjs_events

Code: [Select]
<html>
<head>
<script type="text/javascript">
function displayDate()
{
var smartness = "Kalphiter is super cool and smart and knowledgable!!";

if(1)
if(1)
if(1)
if(0)
smartness = "Sure is!!";
else
smartness = "nope.avi";

document.getElementById("demo").innerHTML = smartness;
}
</script>
</head>
<body>

<h1>Is Kalphiter Awesome!?</h1>
<p id="demo">Click and find out!</p>

<button type="button" onclick="displayDate()">Display Awesomeness</button>

</body>
</html>


If someone like Space Guy had seen something he thought was amiss, he would have tested it before trying to chastise me. The problem is you're not as smart as Space Guy and when you saw something in untested pseudo-code possibly having a syntax error, you jumped on it and made a post so quickly you didn't even grammar-check it ("Bold is causes a syntax error." - wat) as to point out a "flaw" before I had a chance to "fix" it.


You suck. Give up. Go away.
« Last Edit: February 27, 2011, 06:18:12 PM by Iban »

==> if(false) %a = 1; else %a = 0;echo(%a);
0


==> if(true) %a = 1; else %a = 0;echo(%a);
1


Works with variable setting too. Yes, I'm testing these in-game.
That's not what he did, I know about shorthands. But somehow the engine smashed two statements into a shorthand.

==> if(false) if(false) %a = 1; else %a = 0; else %a = 2;echo(%a);
2
==> if(true) if(false) %a = 1; else %a = 0; else %a = 2;echo(%a);
0


equivalent to:
if(false)
   if(false)
      %a = 1;
   else
      %a = 0;
else
   %a = 2;

echo(%a);


Nested one-line statements work fine.

That wasn't what he did, though.

      if(%row == 0)
         if(%text $= "A")
            %text = "<bitmap:....>";
         else if(%text $= "S")
            %text = "<bitmap:....>";


"if row is 0 then {test two values of text}". The "name" example is irrelevant.
« Last Edit: February 27, 2011, 06:22:14 PM by Space Guy »

if(false)
   if(false)
      %a = 1;
   
else
     
%a = 0;
else
   %a = 2;

echo(%a);

It doesn't make sense how that's even possible.