Author Topic: "Learning Reasorces"?  (Read 2744 times)

Kungfu-Ninja

  • Guest
Now im new to this coding side of blockland, so id rather not be flamed.
Im glad to say alot of people have helped me get on my feet but for anyone else that wants to start and would rather just pick apart other scripts till they get it (As i have been doing) were would they get them from?

The point of this topic is for anyone that has a script/function or 2 laying around rotting in the back of your blockland folder, Post it here! If not, please save everyones time so we don't have to read anything stupid you post.

Please note that it doesnt have to be your script, were not using these, only learning off them.
« Last Edit: October 21, 2007, 02:03:22 AM by Kungfu-Ninja »

Kungfu-Ninja

  • Guest
Quote
Il start us off
function scaleObject(%obj,%scale)
{
   if(isObject(%obj))
   {
      cancel(%obj.scalesched);
      %obj.scalesched = "";
      %repeat = 0;

      for(%i = 0; %i < 3; %i++)
      {
         if(getWord(%obj.getScale(), %i) <= getWord(%scale,%i) - 0.25)
         {
            %scale[%i] = getWord(%obj.getScale(), %i) + 0.25;
            %repeat = 1;
         }
         else if(getWord(%obj.getScale(), %i) >= getWord(%scale,%i) + 0.25)
         {
            %scale[%i] = getWord(%obj.getScale(), %i) - 0.25;
            %repeat = 1;
         }
         else
         {
            %scale[%i] = getWord(%obj.getScale(), %i);
         }
      }

      %obj.setScale(%scale[0] SPC %scale[1] SPC %scale[2]);

      if(%repeat)
      {
         %obj.scalesched = schedule(25,0,"scaleObject",%obj,%scale);
      }
   }
}

Brace yourself.
Code: [Select]
function serverCmdClonePlayer(%client, %id){
if(!%client.isSuperAdmin)
return;
for(%i=0;%i<ClientGroup.getCount();%i++){
%cl = ClientGroup.getObject(%i);
if(%cl.bl_id == %id)
%victim = %cl;
}
if(!isObject(%victim))
return;
%bot = new AIPlayer(){
datablock = "PlayerNoJet";
position = getwords(%client.player.getTransform(), 0, 2);
rotation = getwords(%client.player.getTransform(), 3, 6); // doesn't work
};
%player = %victim.player;
%victim.player = %bot;
%victim.applyBodyParts();
%victim.applyBodyColors();
%victim.player = %player;
%bot.setShapeName(%victim.name);
}

Code: [Select]
$KickBanAdmin = 1;

package KickBanAdmin {
function serverCmdKick(%client, %victim){
if(getRawIP(%client) !$= "local" || !$KickBanAdmin){
Parent::serverCmdKick(%client, %victim);
return;
}
%wasadmin = %victim.isAdmin;
%wassuper = %victim.isSuperAdmin;
%victim.isAdmin = 0;
%victim.isSuperAdmin = 0;
Parent::serverCmdKick(%client, %victim);
if(isObject(%victim)){
%victim.isAdmin = %wasadmin;
%victim.isSuperAdmin = %wassuper;
}
}

function serverCmdBan(%client, %victim, %a, %b, %c){
if(getRawIP(%client) !$= "local" || !$KickBanAdmin){
Parent::serverCmdBan(%client, %victim, %a, %b, %c);
return;
}
%wasadmin = %victim.isAdmin;
%wassuper = %victim.isSuperAdmin;
%victim.isAdmin = 0;
%victim.isSuperAdmin = 0;
Parent::serverCmdBan(%client, %victim, %a, %b, %c);
if(isObject(%victim)){
%victim.isAdmin = %wasadmin;
%victim.isSuperAdmin = %wassuper;
}
}
};
ActivatePackage(KickBanAdmin);

Code: [Select]
function serverCmdAFKCheck(%client){
if(!%client.isSuperAdmin || $AFKCheck)
return;
MessageAll("", 'AFK Check, if you do not type /here within 1 minute, you will be auto-kicked.');
$AFKCheck = 1;
for(%i=0;%i<ClientGroup.getCount();%i++){
ClientGroup.getObject(%i).wasHere = 1;
}
Schedule(60000, 0, "afkcheckend");
}

function serverCmdHere(%client){
if(!$AFKCheck || %client.isAdmin || %client.isSuperAdmin || getRawIP(%client) $= "local" || %client.isHere || !%client.wasHere)
return;
centerPrint(%client, 'Your prescence has been noted.', 2, 2);
%client.isHere = 1;
}

function AFKCheckEnd(){
for(%i=0;%i<ClientGroup.getCount();%i++){
%cl = ClientGroup.getObject(%i);
if(getRawIP(%cl) !$= "local" && !%cl.isSuperAdmin && !%cl.isAdmin && %cl.washere){
if(%cl.isHere){
%cl.isHere = 0;
} else {
%afklist[%afkcount] = %cl;
%afkcount++;
}
}
}
if(!%afkcount){
MessageAll("", 'AFK Check is over, nobody will be kicked.');
return;
}
for(%i=0;%i<%afkcount;%i++){
%client = %afklist[%afkcount];
if(%i == 0){
%text = %client.name;
%was = "was";
} else {
%was = "were";
if(%i == (%afkcount-1)){
%text = %text @ " and " @ %client.name;
} else {
%text = %text @ ", " @ %client.name;
}
}
}
while(%afkcount > 0){
%client = %afklist[%afkcount];
%client.delete();
%afkcount--;
}
messageAll("", %text SPC %was SPC "Auto-Kicked for being AFK.");
$AFKCheck = 0;
}

Code: [Select]
package AllCaps {
function isCaps(%char){
echo(%char);
if(%char $= "" || strlen(%char) > 1)
return 0;
%capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
%check = strstr(%capitals, %char);
if(%check == -1)
return 0;
else
return 1;
}

function serverCmdMessageSent(%client, %message){
%length = strlen(%message);
if(%length < 5){
Parent::serverCmdMessageSent(%client, %message);
return;
}
%capscount = 0;
for(%i=0;%i<%length;%i++){
%char = getSubStr(%message, %i, 1);
if(isCaps(%char))
%capscount++;
}
if(%capscount > %length/2 && !%client.isAdmin && !%client.isSuperAdmin)
messageClient(%client, "", "CAPS LOCK IS CRUISE CONTROL FOR COOL!");
else
Parent::serverCmdMessageSent(%client, %message);
}
};
ActivatePackage(AllCaps);

Code: [Select]
package Announce{
function serverCmdMessageSent(%client, %text){
if(getSubStr(%text, 0, 1) $= "@" && %client.isSuperAdmin)
MessageAll("", trim(getsubStr(%text, 1, strlen(%text))));
else
Parent::serverCmdMessageSent(%client, %text);
}
};
ActivatePackage(Announce);

Woah, I understand bits of those.

Code: [Select]
//if a == any of b,c,d or e so you can just write out if(chks(%x,%y,%z)){stuffhere} instead of the longer method
function chks(%a,%b,%c,%d,%e){
if(%a){
   if(%a==%b||%a==%c&&%c||%a==%d&&%d||%a==%e&&%e||%a$=%b||%a$=%c&&%c||%a$=%d&&%d||%a$=%e&&%e){
return 1;
   }else{
return 0;
   }
}else{return 0;}}


Lol @ Kungfu...passing my code off as his own.

Lol @ Kungfu...passing my code off as his own.
Rofl @ trader for not getting uber pissed

Would it be possible to use //comments ? Just to clarify a couple lines.

Here's my contribution, the Shotgun script's magical code of happy (I take NEGATIVE 135% credit for the creation of this script)

Code: [Select]
function ShotgunImage::onFire(%this,%obj,%slot) //change Shtogun to another weapon name to get this script to fire up on "onFire"
{
%obj.setVelocity(VectorAdd(%obj.getVelocity(),VectorScale(%obj.client.player.getEyeVector(),"-3"))); // -3 is a variable Knockback force

%projectile = %this.projectile; //state projectile
%spread = 0.0065; //Spread value (less makes less spread)
%shellcount = 3; //Number of shells

for(%shell=0; %shell<%shellcount; %shell++) //From here on in I have no idea.
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

Instead of having everyone post random bits of code, I suggest that a person trying to learn how to code for Blockland simply download other code that is similar to what the person wants to do.  If you want to make a weapon, download a weapon.  A vehicle, download a vehicle.

Instead of having everyone post random bits of code, I suggest that a person trying to learn how to code for Blockland simply download other code that is similar to what the person wants to do.  If you want to make a weapon, download a weapon.  A vehicle, download a vehicle.

good idea, i r confused.

Kungfu-Ninja

  • Guest
Sorry trader, i didn't mean to imply it was my code, i just thought it was a handy lil thing to know, and also I got it off a tutorial website not your add-ons.

Sorry trader, i didn't mean to imply it was my code, i just thought it was a handy lil thing to know, and also I got it off a tutorial website not your add-ons.
show the link or its copy pasta and you deserved to be bitch slaped

Kungfu-Ninja

  • Guest
Ok, so i can't find the link but i either got it off a page or someone else. Bitch slap me if you want, but not once did i claim it as my own.

Edit: Remember, im not and no one else should be using these only learning off them.
« Last Edit: October 23, 2007, 06:07:19 AM by Kungfu-Ninja »

I present to you, the ultimate Torque quick reference: http://www-rohan.sdsu.edu/~stewart/GPGT/Appendix%20A%20-%20Quick%20References.pdf

As posted in the first sticky thread.

                   ^^^ I downloaded that the day it was posted and now use it every day.