Author Topic: Making sure someone is on the race  (Read 1288 times)

techwarfare

  • Newbie
  • *
  • Posts: 18
    • View Profile
Making sure someone is on the race
« on: February 15, 2015, 05:27:55 AM »
Hey i created my race with a simple give weapon, for an ak but the problem is that everyone who is at least on the server gets the gun and the ammo.

Code: [Select]
#include <sourcemod>
#include "W3SIncs/War3Source_Interface"
#include "W3SIncs/War3Source_Addon_AmmoControl"

public Plugin:myinfo = {
name = "Terran Earth Marine",
author = "Techy",
description = "Race for ssg war3source",
};

new thisRaceID;

new bool:RaceDisabled=true;
public OnWar3RaceEnabled(newrace)
{
if(newrace==thisRaceID)
{
RaceDisabled=false;
}
}
public OnWar3RaceDisabled(oldrace)
{
if(oldrace==thisRaceID)
{
RaceDisabled=true;
}
}

new Float:Extradamage[5] = {0.0, 0.2, 0.4, 0.6, 0.8};
new Float:Health[5] = {0, 5, 10, 15, 20};
//new Float:Akchance[5] = {1.0, 1.20, 1.4, 1.6, 1.8};
new Float:AttackSpeed[5] = {1.0, 1.05, 1.10, 1.15, 1.20}; //Attacking speed
new Float:Stim[5] = {0.0, 2.0, 2.5, 3.0, 3.5};  //Health Regen

new SKILL_EXTRADMG, SKILL_HP, SKILL_ATTSPD, SKILL_STIM;

public OnPluginStart()
{
HookEvent("player_spawn", playerSpawn);
HookEvent("round_start", roundStart);
}

public OnWar3LoadRaceOrItemOrdered(num)
{
if(num == 80)
{
thisRaceID = War3_CreateNewRace("Terran", "TerranSpaceMarine", 0);

SKILL_EXTRADMG = War3_AddRaceSkill(thisRaceID, "ExtraDamage", "ExtraDamage", false, 4);
SKILL_HP = War3_AddRaceSkill(thisRaceID, "ExtraHP", "ExtraHP", false, 4);
//SKILL_AK = War3_AddRaceSkill(thisRaceID, "AkChance", false, 4, "80%");
SKILL_ATTSPD = War3_AddRaceSkill(thisRaceID, "AttSpeed", "AttSpeed", false, 4);
SKILL_STIM = War3_AddRaceSkill(thisRaceID, "Stim", "Stim", false, 4);

War3_CreateRaceEnd(thisRaceID);

War3_AddSkillBuff(thisRaceID, SKILL_EXTRADMG, fDamageModifier, Extradamage);
War3_AddSkillBuff(thisRaceID, SKILL_HP, iAdditionalMaxHealth, Health);
//War3_AddSkillBuff(thisRaceID, SKILL_AK, fAkChance, AkChance);
War3_AddSkillBuff(thisRaceID, SKILL_ATTSPD, fAttackSpeed, AttackSpeed);
War3_AddSkillBuff(thisRaceID, SKILL_STIM, fHPRegen, Stim);
}
}

public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
if(RaceDisabled == false)
{
GivePlayerItem(client, "weapon_ak47");

War3_GiveWeaponAmmo(client, "weapon_ak47", _, 200);
}
if(RaceDisabled == true)
{
return Plugin_Handled;
}
return Plugin_Handled;
}

public Action:playerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client_id = GetEventInt(event, "userid");
new client = GetClientOfUserId(client_id);

CreateTimer(0.1, giveWeapon, client);
}

public Action:giveWeapon(Handle:timer, any:client)
{
if(RaceDisabled == false)
{
new iWeapon = GivePlayerItem(client, "weapon_ak47");

War3_GiveWeaponAmmo(client, iWeapon, _, 200);
CloseHandle(timer);
}
if(RaceDisabled == true){
CloseHandle(timer);
}
}

This is what i have so far, would be good if anyone could help.

Thanks,
Techy.

Ownz

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2437
  • chmod -R 777 *
    • View Profile
    • OwnageClan
Re: Making sure someone is on the race
« Reply #1 on: February 15, 2015, 10:30:07 AM »
OnWar3RaceEnabled OnWar3RaceDisabled is meant to enable and disable the whole race

Action:playerSpawn needs to check player race, of the player in the spawn event

War3_GetRace(client)


Quote
if(War3_GetRace(client)==thisRaceID && ValidPlayer(client,true))
    {
        new skilllvl = War3_GetSkillLevel(client,thisRaceID,SKILL_TRIBUNAL);
        if(skilllvl > 0)
    {
            //do stuff
     }
 }       

see other races for examples

scripting API lookup is here: http://ownageclan.com/war3source/functionreference/?search=war3_getRace%28client%29
« Last Edit: February 15, 2015, 10:32:01 AM by Ownz »