Author Topic: Variable & Value Help [Answered]  (Read 1279 times)

Well thanks to everyone who helped with my last question but I have one more, you see, I find it hard finding game built variables and values.

Like how would I get a clients score, health, playertype, and maybe their active item slot.

I don't actually need those exact things, but how would I go about finding these myself?  Without looking at another code for it.
Also, how would I find these using a client mod and a server mod
« Last Edit: August 26, 2012, 07:33:21 PM by ¥ola »

Well first, use "'s instead of ' 's when making strings.

second, the syntax error is in that ; you have at the very end. remove that.

third, if you want it to actually loop, make that schedule line into this:
schedule(500, 0, RelayLoopJazZ, %client);

I added the %client argument.

Well first, use "'s instead of ' 's when making strings.

second, the syntax error is in that ; you have at the very end. remove that.

third, if you want it to actually loop, make that schedule line into this:
schedule(500, 0, RelayLoopJazZ, %client);

I added the %client argument.

Thank you a lot, but can you explain the first part a little further for me?

EDIT:
If I understand you correctly
Code: [Select]
package HungerMain
function servercmdStartLoopJazZ(%client)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,"","\c6 Your Not Admin");
}
};
activatepackage(HungerMain);

function RelayLoopJazZ(%client)
{
messageClient(%client,"","\c6 Worked.");
}
That is correct?

DOUBLEDIT:
It tells me there's a syntax error on line 2 of server.cs
I cannot find it
« Last Edit: August 25, 2012, 06:08:00 PM by ¥ola »

oh, your package needs to have braces.

Code: [Select]
package HungerMain
{
function servercmdStartLoopJazZ(%client)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,'',"\c6 Your Not Admin");
}
}
};
activatepackage(HungerMain);

function RelayLoopJazZ(%client)
{
messageClient(%client,'',"\c6 Worked.");
}
try that.

Thank you very much, works perfectly now except for it doesn't loop through it.

It will display "Worked." once after I type the command but will not loop it.
How would I get about to doing that?

Code: [Select]
package HungerMain
{
function servercmdStartLoopJazZ(%client)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,'',"\c6 Your Not Admin");
}
}
};
activatepackage(HungerMain);

function RelayLoopJazZ(%client)
{
messageClient(%client,'',"\c6 Worked.");
schedule(500, 0, RelayLoopJazZ, %client);
}

But please note that it won't stop unless you overwrite the function, so you should have some method of stopping it.

Code: [Select]
package HungerMain
{
function servercmdStartLoopJazZ(%client)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,'',"\c6 Your Not Admin");
}
}
};
activatepackage(HungerMain);

function RelayLoopJazZ(%client)
{
messageClient(%client,'',"\c6 Worked.");
schedule(500, 0, RelayLoopJazZ, %client);
}

But please note that it won't stop unless you overwrite the function, so you should have some method of stopping it.

To stop a schedule, give it a variable name, such as %client.jazzloop = schedule(...);
Then, to stop it, you can use

Code: [Select]
if(isEventPending(%client.jazzloop)) //checks if the schedule exists
{
    cancel(%client.jazzloop); //terminates the schedule
}

To stop a schedule, give it a variable name, such as %client.jazzloop = schedule(...);
Then, to stop it, you can use

Code: [Select]
if(isEventPending(%client.jazzloop)) //checks if the schedule exists
{
    cancel(%client.jazzloop); //terminates the schedule
}
Thank you, I actually just wrote/tested a stopping method but is has simple issue


Code: [Select]
package HungerMain
{
function servercmdStartLoopJazZ(%client)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
$LoopActivation = 1;
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,"","\c6 Your Not Admin");
}
}

function servercmdStopLoopJazZ(%client)
{
if(%client.isSuperAdmin || %client.isAdmin)
{
$LoopActivation = 0;
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,"","\c6 Your Not Admin");
}
}
};
activatepackage(HungerMain);

function RelayLoopJazZ(%client)
{
if($LoopActivation == 1)
{
messageClient(%client,"","\c6 Worked.");
schedule(500, 0, RelayLoopJazZ, %client);
}
else
{
messageClient(%client,"","\c6 Loop Stopped.");
}
}
That code works with no syntax errors at all, but when I use /StopLoopJazZ it displays "Loop Stopped." twice, any way I can prevent this?

That would be because you started another loop for it, when another was already going. Just remove line 21 and it'l work.

That would be because you started another loop for it, when another was already going. Just remove line 21 and it'l work.
I see what your saying, thanks

Alright, I have it fully working an I think I understand this a little better, thanks a ton Ipquarx and Wheatly

EDIT;
New question, please read OP
« Last Edit: August 25, 2012, 07:13:42 PM by ¥ola »

First, it's better that you make a new topic instead of editing the current one if the subject isn't very closely related. That way if someone searches for keywords, they can find what they need.

Now, on to your question:

Getting each value you need can be different based on if its from a client-side mod or a server-side mod.
I'll use your examples to help show this, because each one is obtained using a different method.

clients score, health, playertype, and maybe their active item slot.
To get a client's score, you would need to be using a serverside mod, i.e., you would need to be hosting the server to be able to use it. You can obtain a client's score by echoing the client's score variable:
echo(%client.score);

Getting a player's health is also serverside only. You would need to echo an equation to get their remaining health; however, I will give you the function used to get the health they're lost.
echo(%player.getDamagePercent()); - this will echo how much health they've lost as a percent, where 100% would be their max health.

Getting a playertype is accessible from both server and clientside scripts. However, in a clientside script, you can only get your own playertype.
serverside: %player.getDataBlock() to get their datablock, or %player.getDataBlock().uiname to get the displayed name of their playertype, such as "Standard Player".
clientside: serverConnection.player.getDataBlock() will give you your current datablock.


Without looking at another code for it.
I didn't notice this bit until I wrote all that. No, you should be looking at other codes for it. That's one of the best ways to learn Torquescript.
If you think you know of an add-on that may have what you need to do, open it, read it, understand it.

%client.score is their score.

-snip-
Alright, I'll keep doing that, thank you for the information though.

%client.score is their score.
Thanks.

So there is no possible way to get your own score using a client sided mod?

EDIT:
Also, going off of the original post itself I need help with figuring out a good way to do something, I'll explain
Using a server sided mod, I want to lets say take away 1 health from every player on the server every 10 seconds, how can I cause this to happen to every single player on the server from when they spawn to when they leave
« Last Edit: August 25, 2012, 08:34:11 PM by ¥ola »

there is a way to get your own score client sidedly.

Code: [Select]
function getMyScore()
{
%Count = NPL_List.rowCount();

for(%a = 0; %a < %Count; %a++)
{
%Row = NPL_List.getRowText(%a);
if(getField(%Row, 1) $= $pref::Player::NetName)
return getField(%Row, 2);
}
}