Author Topic: Questions  (Read 4790 times)

So if I assign a variable to a player could I call that variable in another script?
Yes

Assigning a variable to an object like:
%client.var1
%client.player.var2
etc...
Assigns the variable globally

Code: [Select]
function serverCmdreset(%client)
{
%client.Roleplay["Class"] = "NONE";
%client.Roleplay["Race"] = "NONE";
%client.Roleplay["Gold"] = 100;
%client.Roleplay["EXP"] = 0;
%client.Roleplay["LEvel"] = 1;
%client.player.setPlayerScale("1 1 1");
%client.Roleplay["EXPreq"] = 30;
%client.ammo["Bow"] = 15;
messageClient(%client, '', "\c6You reset.");
}
Code: [Select]
function BowImage::onreload(%this, %obj, %slot)
{
if(%this.ammo["Bow"] > 0)
%obj.ammo["bow] +=  %this.ammo["Bow"];
%this.ammo["Bow"] -= %this.ammo["Bow"];


    if(%obj.ammount$="")
%obj.ammount=0;
    %obj.ammo["Bow"]+=%obj.ammount;
echo("reload?");
centerPrint(%obj.client, "<just:right>0/15");
}
function BowImage::checkammo(%this,%obj,%slot)
{
    if(%obj.ammo["Bow"]$="")%obj.ammo["BOw"]=$ammo::default["Bow"];
    if(%obj.ammo["Bow"])%obj.setimageammo(%slot,1);
    centerPrint(%obj.client, "<just:right>"@%obj.ammo["Bow"]@"/15");
}
doesn't work. doesn't add the ammo

You're checking for %obj.ammo, not %client.ammo. So when you add to %client.ammo, it does nothing.

Try %client.player.ammo

Ah, so %this is the player, not client.

Ah, so %this is the player, not client.
Not always.
The first argument of all methods is the object being called (GameConnection, Player, Etc.).
Usually %this is named as the first argument of a method.

How would I check if the horse collides with a player?

I have some questions.

1. I am editing my fire mod and I want it to have a 1/4 chance to do something. How would I do a 1 in 4 chance?
if(getRandom(1,4) == 1)
{
//do stuff
}


2. Checking for explosion damage.
How do I check if something is damaged by an explosion?
Tough question.

For the explosions part:
Code: [Select]
function PlayerPortal::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
   if(%damageType == $DamageType::Fall || %damageType == $DamageType::Impact)
Maybe this snip could be usefull? :/
I don't know, just suggesting.

if(getRandom(1,4) == 1)
{
//do stuff
}

Tough question.
I solved the radius one. I just did a container search and killed all bricks in the area. Now about the horse one?

I solved the radius one. I just did a container search and killed all bricks in the area. Now about the horse one?
OnCollision function?

How would I check if the horse collides with a player?

Armor::onCollision(%this,%col, or w/e look at another script for these)
{
if(%this.dataBlock.getName() !$= "HorseArmor" && %col.dataBlock.getName() $= "HorseArmor")
}

something like that.

Armor::onCollision(%this,%col, or w/e look at another script for these)
{
if(%this.dataBlock.getName() !$= "HorseArmor" && %col.dataBlock.getName() $= "HorseArmor")
}

something like that.
Best thing to do. :P

Armor::onCollision(%this,%col, or w/e look at another script for these)
{
if(%this.dataBlock.getName() !$= "HorseArmor" && %col.dataBlock.getName() $= "HorseArmor")
}

something like that.
What about checking to make sure the Col is a player? I want it so it can collide with any player but another horse

What about checking to make sure the Col is a player? I want it so it can collide with any player but another horse
Code: [Select]
Armor::onCollision(%this,%col, or w/e look at another script for these)
{
   parent::oncollision(%this,%col, or w/e look at another script for these);
   if(%this.dataBlock.getName() !$= "HorseArmor" && %col.dataBlock.getName() $= "HorseArmor")
   {
      return;
   }
   else
   {
      //put no collision script here, though it is impossible to make that as far as i know
   }
}
I putted in parenting, as that is needed for a less buggy script...
Also, correct me if i am wrong.

What about making a player tumble?