Hello !
I got a problem with Hero: Cartman... So the problem is when the round starts and after the freeze time the player can just use cartman and then he wil spawn in the other teams base or hes own base.. i would like to edit the hero so you can only teleport to your OWN base and not your enemy base because this hero can be used like "Catwoman"... here is the .sma code:
EDIT: And problem number 2 is the sound, because whenever a player press the bind key for cartman, all players can hear the sound of cartman.. i want it so only players in a radius of 300-400 would hear it if that is possible, or only the player himself...
Code:
//CARTMAN!
/* CVARS - copy and paste to shconfig.cfg
//Cartman
cartman_level 6
cartman_cooldown 30.0
cartman_delay 2.0 //delay til teleport
cartman_nadedelay 8.0 //delay til new nade
*/
#include <amxmod>
#include <superheromod>
new gHeroName[]="Cartman"
new bool:g_hasCartmanPower[SH_MAXSLOTS+1]
new bool:gHasSpawnPoint[SH_MAXSLOTS+1]
new userSpawn[3]
#define AMMOX_HEGRENADE 12
public plugin_init() {
register_plugin("SUPERHERO Cartman","1.0","-=cKy=- <Killer>")
register_cvar("cartman_level", "6")
register_cvar("cartman_cooldown", "80.0")
register_cvar("cartman_delay", "2.2")
register_cvar("cartman_nadedelay", "8.0")
shCreateHero(gHeroName, "Escape from enemies", "Press bind key to teleport back to your spawn point! Also get nade refills!", true, "cartman_level")
register_srvcmd("cartman_kd", "cartman_kd")
shRegKeyDown(gHeroName, "cartman_kd")
register_srvcmd("cartman_init", "cartman_init")
shRegHeroInit(gHeroName, "cartman_init")
register_event("ResetHUD", "newRound", "b")
//Find Thrown Grenades
register_event( "AmmoX", "on_AmmoX", "b" )
}
public plugin_precache() {
precache_sound("shmod/cartman_home.wav")
}
public cartman_init() {
new temp[6]
read_argv(1, temp, 5)
new id=str_to_num(temp)
read_argv(2, temp, 5)
new hasPowers=str_to_num(temp)
g_hasCartmanPower[id] = (hasPowers!=0)
gPlayerUltimateUsed[id] = false
gHasSpawnPoint[id]=false
if ( g_hasCartmanPower[id] && is_user_alive(id) ) {
get_nade(id)
}
}
public get_nade(id) {
if ( is_user_alive(id) && g_hasCartmanPower[id] ) {
shGiveWeapon(id, "weapon_hegrenade" )
}
}
public newRound(id) {
if ( g_hasCartmanPower[id] && is_user_alive(id) ) {
new origin[3]
get_user_origin(id, origin, 0)
userSpawn[0]=origin[0]
userSpawn[1]=origin[1]
userSpawn[2]=origin[2]
gPlayerUltimateUsed[id] = false
gHasSpawnPoint[id]=true
get_nade(id)
}
}
public cartman_kd() {
new temp[6]
read_argv(1,temp,5)
new id=str_to_num(temp)
if ( !is_user_alive(id) || !g_hasCartmanPower[id] || !hasRoundStarted() ) return
if ( gPlayerUltimateUsed[id] ) {
playSoundDenySelect(id)
return
}
if ( !gHasSpawnPoint[id] ) {
client_print(id,print_chat,"[Cartman] No spawn point saved yet, wait til next round..")
return
}
shGlow(id, 0, 255, 128)
new sndplayers[SH_MAXSLOTS], sndnum
get_players(sndplayers, sndnum, "ac")
for (new x = 0; x < sndnum; x++) {
emit_sound(sndplayers[x], CHAN_AUTO, "shmod/cartman_home.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
set_task( get_cvar_float("cartman_delay"), "cartman_escape", id+520 )
ultimateTimer( id, get_cvar_float("cartman_cooldown") )
}
public cartman_escape(id) {
id-=520
set_user_origin(id, userSpawn)
shUnglow(id)
}
public on_AmmoX(id)
{
if ( !shModActive() ) return
if ( id <= 0 || id > SH_MAXSLOTS) return
if ( !is_user_alive(id) || !is_user_connected(id) ) return
new iAmmoType = read_data(1)
new iAmmoCount = read_data(2)
if ( iAmmoType == AMMOX_HEGRENADE && iAmmoCount == 0 && g_hasCartmanPower[id]) {
set_task( get_cvar_float("cartman_nadedelay"), "get_nade", id )
}
}
__________________