Hi everyone,
i got a little problem that i can't make it work, it should work due to other systems it's begin used in.
it doesn't hurt other players.
-System/Spells:
PHP Code:
function onActionServerside(cmd,p1,p2,p3) {
if (cmd == "TakeMana")
clientr.mana -= p1;
}
//#CLIENTSIDE
public function fireSpell(stats) {
//fired from the spell weapon
temp.spellName = stats[0];
temp.action = stats[1];
temp.cast = stats[2];
temp.ani = stats[3]; //projectile
temp.mana = stats[4];
temp.freeze = stats[5];
temp.power = stats[6];
temp.cooldown = stats[7];
if (mana > clientr.mana) {
player.chat = "You don't have enough mana to cast " @spellName@ ".";
//if you have a message system you can use that instead
return;
}
if (this.("cooldown_" @spellName) != null) {
player.chat = spellName@ " is still cooling down for " @this.("cooldown_" @spellName)@ " seconds.";
//if you have a message system you can use that instead
return;
}
if (action == "hurt") { //a spell that hurts a player
if (cast == "projectile") { //a hurt spell that is a projectile
freezePlayer(freeze);
setani("grab",null); //placeholder
sleep(freeze);
setShootParams("spell","heal",power,player.account,player.guild);
temp.angle = getangle(vecx(player.dir),vecy(player.dir)); //shoots in a straight line
shoot(player.x+vecx(player.dir),player.y+vecy(player.dir),player.z,angle,0,0,ani,null);
}
}
if (action == "heal") { //a spell that heals a player
if (cast == "projectile") { //a heal spell that is a projectile
freezePlayer(freeze);
setani("grab",null); //placeholder
sleep(freeze);
setShootParams("spell","heal",power,player.account,player.guild);
temp.angle = getAngle(vecx(player.dir),vecy(player.dir)); //shoots in a straight line
shoot(player.x+vecx(player.dir),player.y+vecy(player.dir),player.z,angle,1,0,ani,null);
}
if (cast == "self") { //a heal spell that is cast on yourself
freezePlayer(freeze);
setani("grab",null); //placeholder
sleep(freeze);
//go to health system and heal using the amount 'random(int(power[0],power[1]))'
}
}
triggerServer("gui","-System/Spells","TakeMana",mana);
makeVar("this.cooldown_" @spellname) = cooldown;
scheduleEvent(0.05,"Cooldown",spellName);
}
function onCooldown(spellName) {
if (this.("cooldown_" @spellName) > 0) {
makeVar("this.cooldown_" @spellName) -= 0.05;
scheduleEvent(0.05,"Cooldown",spellName);
}
}
function onActionProjectile(spell,action,power,pl,pguild) {
if (spell == "spell") { //make sure it's a spell and not some other projectile
if (action == "hurt") {
temp.hurtable = CheckHurtable(pl, pguild); //Here's the problem (i think.)
if (temp.hurtable && clientr.hp > 0)
{
player.chat = temp.hurtable;
temp.powerdmg = int(random(power[0],power[1]));
triggerserver("weapon", "-System/Health", "TakeDamage", temp.powerdmg, pl);
client.immunity = 1;
player.attr[20] = "noc_damage.gani,-" @ temp.powerdmg;
scheduleevent(0.5, "UnSetAttr", "");
client.LastAttacker = pl;
setani("hurt","");
// player.chat = clientr.hp; <- debug
}
}
if (action == "heal") {
//go to health system and heal using the amount 'random(int(power[0],power[1]))'
}
}
}
function onUnSetAttr()
{
client.immunity = 0;
player.attr[20] = "";
cancelEvents("UnSetAttr");
}
function CheckHurtable( pl, gd)
{
if(gd == "Newbie Protection" || player.guild == "Newbie Protection")return;
if(pl == player.account)return false;
if(level.nopkzone)return false;
if(client.sparstatus == 1)return false;
if(client.dead)return false;
if(clientr.dead)return false;
if(clientr.stafftag == player.guild && clientr.stafftag != NULL)return false;
if(gd == "Working" || gd == "Events Team")return false;
if(player.guild == "Working" || player.guild == "Events Team")return false;
if(client.immunity > 0)return false;
if(player.guild == gd)
if(player.guild != NULL)
if(gd != NULL)
return false;
return true;
}
Spells/Test:
PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
temp.stats = {
"Test", //name
"hurt", //action
"projectile", //cast
"tl_fire", //projectile animation
20, //mana
0.5, //freeze
{1,5}, //power
2, //cooldown
};
findWeapon("-System/Spells").fireSpell(stats);
setani("idle",null);
}
Credits for this script goes to Switch.
a part of the
-System/Health
PHP Code:
function onActionServerSide(id)
{
switch(id)
{
case "TakeDamage":
if(clientr.hp <= 0 || clientr.specialpkzone == true)
return;
temp.dmg = params[1];
temp.pl = params[2];// no idea why this is here but ohwell.
player.attr[16] = dmg; // no idea why this is here but ohwell.
player.attr[15] = "noc_damage.gani";// no idea why this is here but ohwell.
if(clientr.hp > 0)
clientr.hp -= temp.dmg;
break;
}
}
please notice that the heath system is used by other systems, so it might not be the thing that breaks it but i included it in-case of.