Raised This Month: $51 Target: $400
 12% 

Hero: Cartman problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SimonLANO
Member
Join Date: Dec 2008
Old 07-07-2012 , 16:42   Hero: Cartman problem
Reply With Quote #1

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 )
	}
}
__________________
[SS]Superhero By 8Ball | 10 Free Levels | Max 50 Level | FastDL


Join us now !

Last edited by SimonLANO; 07-07-2012 at 16:44.
SimonLANO is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 07-07-2012 , 21:41   Re: Hero: Cartman problem
Reply With Quote #2

Change this:
PHP Code:
new sndplayers[SH_MAXSLOTS], sndnum
    get_players
(sndplayerssndnum"ac")
    for (new 
0sndnumx++) {
        
emit_sound(sndplayers[x], CHAN_AUTO"shmod/cartman_home.wav"VOL_NORMATTN_NORM0PITCH_NORM)
    } 
To just one line:

PHP Code:
        emit_sound(idCHAN_AUTO"shmod/cartman_home.wav"VOL_NORMATTN_NORM0PITCH_NORM
Now the sound will only play for the person using cartman.

As for the random spawn thing...

What is does is catching where a player spawns when he does, then uses that point to teleport the player to, so that shouldn't happen. But I am not really sure if the forward newRound returns a player ID. I will have to look into that first before I can confirm that. Let me sleep on it.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
SimonLANO
Member
Join Date: Dec 2008
Old 07-07-2012 , 21:58   Re: Hero: Cartman problem
Reply With Quote #3

Okay thanks jelle i wil look tomorrow then
__________________
[SS]Superhero By 8Ball | 10 Free Levels | Max 50 Level | FastDL


Join us now !
SimonLANO is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 07-10-2012 , 08:52   Re: Hero: Cartman problem
Reply With Quote #4

problem is the there is only one saved spawn since the variable holding that data isn't indexed, solution would be to make it a double indexed array like so
PHP 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[SH_MAXSLOTS+1][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(1temp5)
    new 
id=str_to_num(temp)
    
    
read_argv(2temp5)
    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(idorigin0)
    
        
userSpawn[id][0]=origin[0]
        
userSpawn[id][1]=origin[1]
        
userSpawn[id][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(id0255128)
    
    new 
sndplayers[SH_MAXSLOTS], sndnum
    get_players
(sndplayerssndnum"ac")
    for (new 
0sndnumx++) {
        
emit_sound(sndplayers[x], CHAN_AUTO"shmod/cartman_home.wav"VOL_NORMATTN_NORM0PITCH_NORM)
    }
    
    
set_taskget_cvar_float("cartman_delay"), "cartman_escape"id+520 )
    
    
ultimateTimeridget_cvar_float("cartman_cooldown") )
}

public 
cartman_escape(id) {
    
    
id-=520
    set_user_origin
(iduserSpawn[id])

    
shUnglow(id)
}

public 
on_AmmoX(id)
{
    if ( !
shModActive() ) return
    if ( 
id <= || 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 == && g_hasCartmanPower[id]) {
        
set_taskget_cvar_float("cartman_nadedelay"), "get_nade"id )
    }

__________________
If at first you don't succeed, then skydiving isn't for you.
G-Dog is offline
Send a message via AIM to G-Dog
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode