i have gundam on my server and when i kill with the m4 (green arrow shots) it doesnt give me XP anyone know why?
Code:
#include <amxmod.inc>
#include <amxmisc>
#include <xtrafun>
#include <vexd_utilities>
#include <superheromod.inc>
// Strike Gundam
// GLOBAL VARIABLES
new gHeroName[]="Strike Gundam"
new bool:gHasgundamPower[SH_MAXSLOTS+1]
new bool:gmorphed[SH_MAXSLOTS+1]
new ggundamSound[]="items/suitchargeno1.wav"
new ggundamsFired[33] = 0
new gSpriteWhite, gRadius, gBright
new gTaskID
#define TE_USERgundam 127
new gLastWeapon[33]=0
new gLastClipCount[33]=0
new lastammo[33]
new lastweap[33]
new spr_laser
new spr_fireball
new spr_fxplode1
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Strike Gundam", "1.0", "thechosenone")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("gundam_level", "14")
register_cvar("gundam_teamglow", "0")
register_cvar("gundam_health", "200")
register_cvar("gundam_armor", "350")
register_cvar("gundam_gravity", ".35")
register_cvar("gundam_speed", "900")
register_cvar("gundam_radius", "1000")
register_cvar("gundam_bright", "128")
if ( !cvar_exists("gundam_shot") ) register_cvar("gundam_shot", "3")
if ( !cvar_exists("gundam_getm4a1") ) register_cvar("gundam_getm4a1", "1")
if (get_cvar_num("gundam_mode")!=1){
shCreateHero(gHeroName, "Strike Gundam", "See Bullets/ESP/Gravity/Gundam Model", false, "gundam_level" )
}else{
shCreateHero(gHeroName, "Strike Gundam", "See Bullets/ESP/Gravity/Gundam Model", false, "gundam_level" )
}
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("gundam_init", "gundam_init")
shRegHeroInit(gHeroName, "gundam_init")
register_event("Damage", "gundam_damage", "b", "2!0")
register_event("ResetHUD","newRound","b")
register_event("CurWeapon","changeWeapon","be","1=1")
register_event("CurWeapon","make_tracer", "be", "1=1", "3>0")
register_event("ResetHUD", "newSpawn", "b")
register_event("CurWeapon", "weaponChange", "be", "1=1")
register_event("CurWeapon", "make_gundam", "be", "1=1", "3>0")
register_event("DeathMsg", "gundam_death", "a")
//ESP Rings Task
set_task(2.0, "gundam_esploop", 0, "", 0, "b")
//Set a random number to the looping task so it can be removed without conflict
gTaskID = random_num(10181, 100000)
// Let Server know about Strike Gundam Variables
shSetShieldRestrict(gHeroName)
shSetMaxHealth(gHeroName, "gundam_health")
shSetMaxArmor(gHeroName, "gundam_armor")
shSetMinGravity(gHeroName, "gundam_gravity")
shSetMaxSpeed(gHeroName, "gundam_speed", "[0]")
}
//----------------------------------------------------------------------------------------------
public gundam_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has Strike Gundam
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gHasgundamPower[id] = (hasPowers!=0)
//Reset thier shield restrict status
//Shield restrict MUST be before weapons are given out
shResetShield(id)
{
}
if ( is_user_connected(id) ) {
if ( gHasgundamPower[id] ) {
gundam_weapons(id)
gundam_tasks(id)
}
else {
engclient_cmd(id, "drop", "weapon_m4a1")
gundam_unmorph(id)
shRemHealthPower(id)
shRemArmorPower(id)
shRemGravityPower(id)
shRemSpeedPower(id)
}
}
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_model("models/player/Gundam/Gundam.mdl")
precache_sound(ggundamSound)
gSpriteWhite = precache_model("sprites/white.spr")
spr_fireball = precache_model("sprites/shmod/fireball.spr")
spr_fxplode1 = precache_model("sprites/shmod/fxplode1.spr")
spr_laser = precache_model("sprites/laserbeam.spr")
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public newRound(id)
{
new parm[1]
parm[0]=id
ggundamsFired[id] = 0
gPlayerUltimateUsed[id]=false
gLastWeapon[id]=-1 // I think the change Weapon automatically gets called on spawn death too...
if (gHasgundamPower[id] && get_cvar_num("gundam_getm4a1")==1) {
shGiveWeapon(id,"weapon_m4a1")
}
}
//--------------------------------------------------------------------------------------------------------------
public gundam_damage(id)
{
if (!shModActive()) return PLUGIN_CONTINUE
new damage = read_data(2)
new weapon, bodypart, attacker_id = get_user_attacker(id,weapon,bodypart)
if ( attacker_id <=0 || attacker_id>SH_MAXSLOTS ) return PLUGIN_CONTINUE
if ( gHasgundamPower[attacker_id] && weapon == CSW_M4A1 && is_user_alive(id) && (!gPlayerUltimateUsed[attacker_id]))
{
new health = get_user_health(id)
// mah nigga $id wasn't attacked by another player
if (!is_user_connected(attacker_id)) return PLUGIN_CONTINUE
if (attacker_id == id) return PLUGIN_CONTINUE
// damage is less than 10%
if (((1.0 * damage) / (1.0 * (health + damage))) < 0.01) return PLUGIN_CONTINUE
new origin[3]
new attacker_team[2], victim_team[2]
get_user_origin(id, origin)
// player fades..
set_user_rendering(id, kRenderFxFadeSlow, 255, 255, 255, kRenderTransColor, 4);
// beeeg explody!
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(3) // TE_EXPLOSION
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2]-22)
write_short(spr_fxplode1) // mushroom cloud
write_byte(40) // scale in 0.1u
write_byte(12) // frame rate
write_byte(12) // TE_EXPLFLAG_NOPARTICLES & TE_EXPLFLAG_NOSOUND
message_end()
// do turn down that awful racket
// ..to be replaced by a blood spurt!
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(10) // TE_LAVASPLASH
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2]-26)
message_end()
// kill victim
user_kill(id, 1)
message_begin( MSG_ALL, get_user_msgid("DeathMsg"),{0,0,0},0)
write_byte(attacker_id)
write_byte(id)
write_byte(0)
write_string("m4a1")
message_end()
//Save Hummiliation
new namea[24],namev[24],authida[20],authidv[20],teama[8],teamv[8]
//Info On Attacker
get_user_name(attacker_id,namea,23)
get_user_team(attacker_id,teama,7)
get_user_authid(attacker_id,authida,19)
//Info On Victim
get_user_name(id,namev,23)
get_user_team(id,teamv,7)
get_user_authid(id,authidv,19)
//Log This Kill
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"Strike Gundam Blast^"",
namea,get_user_userid(attacker_id),authida,teama,namev,get_user_userid(id),authidv,teamv)
/* set_user_health(id, 0) */
// team check!
get_user_team(attacker_id, attacker_team, 1)
get_user_team(id, victim_team, 1)
// for some reason this doesn't update in the hud until the next round.. whatever.
if (!equali(attacker_team, victim_team)) {
// diff. team; $attacker_id gets credited for the kill and $250 and XP.
// $id gets their suicidal -1 frag back.
set_user_frags(attacker_id, get_user_frags(attacker_id)+1)
set_user_money(attacker_id, get_user_money(attacker_id)+150)
shAddXP(attacker_id, id, 1)
}
else {
// same team; $attacker loses a frag and $500 and XP.
set_user_frags(attacker_id, get_user_frags(attacker_id)-1)
set_user_money(attacker_id, get_user_money(attacker_id)-500, 0)
shAddXP(attacker_id, id, -1)
}
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
//--------------------------------------------------------------------------------------
public make_tracer(id) {
if (!shModActive()) return PLUGIN_CONTINUE
new weap = read_data(2) // id of the weapon
new ammo = read_data(3) // ammo left in clip
if ( gHasgundamPower[id] && weap == CSW_M4A1 && is_user_alive(id) && (!gPlayerUltimateUsed[id]) ) {
if (lastweap[id] == 0) lastweap[id] = weap
if ((lastammo[id] > ammo) && (lastweap[id] == weap)) {
new vec1[3], vec2[3]
get_user_origin(id, vec1, 1) // origin; where you are
get_user_origin(id, vec2, 4) // termina; where your bullet goes
// tracer beam
message_begin(MSG_PAS, SVC_TEMPENTITY, vec1)
write_byte(0) // TE_BEAMPOINTS
write_coord(vec1[0])
write_coord(vec1[1])
write_coord(vec1[2])
write_coord(vec2[0])
write_coord(vec2[1])
write_coord(vec2[2])
write_short(spr_laser) // laserbeam sprite
write_byte(0) // starting frame
write_byte(10) // frame rate
write_byte(2) // life in 0.1s
write_byte(4) // line width in 0.1u
write_byte(1) // noise in 0.1u
write_byte(0) // red
write_byte(153) // green
write_byte(0) // blue
write_byte(80) // brightness
write_byte(100) // scroll speed
message_end()
// bullet impact explosion
message_begin(MSG_PAS, SVC_TEMPENTITY, vec2)
write_byte(3) // TE_EXPLOSION
write_coord(vec2[0]) // end point of beam
write_coord(vec2[1])
write_coord(vec2[2])
write_short(spr_fireball) // blast sprite
write_byte(10) // scale in 0.1u
write_byte(30) // frame rate
write_byte(8) // TE_EXPLFLAG_NOPARTICLES
message_end() // ..unless i'm mistaken, noparticles helps avoid a crash
}
lastammo[id] = ammo
lastweap[id] = weap
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public changeWeapon(id)
{
if ( !gHasgundamPower[id] || !shModActive() ) return PLUGIN_CONTINUE
new clip, ammo
new wpn_id=get_user_weapon(id, clip, ammo);
if ( wpn_id!=CSW_M4A1 ) return PLUGIN_CONTINUE
// This event gets trigger on a switch to a weapon too...
// Easy work around
if ( wpn_id != gLastWeapon[id] )
{
gLastWeapon[id]=wpn_id
return PLUGIN_CONTINUE // user just switched weapons
}
if ( clip >= gLastClipCount[id] )
{
gLastClipCount[id]=clip
return PLUGIN_CONTINUE
}
gLastClipCount[id]=clip
// Ok - if it fell through here - you got a user firing the m4a1
// Bullet Count
ggundamsFired[id]=(ggundamsFired[id] + 1)
new shot = (get_cvar_num("gundam_shot")-ggundamsFired[id])
if (shot == 0) {
gPlayerUltimateUsed[id]=true
}
if (shot <= 0) {
gPlayerUltimateUsed[id]=true
}
if ((shot != 0) && shot >= 0 ) {
new message[128]
format(message, 127, "You Have %d Strike Gundam Blasts Left",shot)
set_hudmessage(255,0,0,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public gundam_esploop()
{
if (!shModActive()) return
new players[SH_MAXSLOTS]
new pnum, vec1[3]
new idring, id
gRadius = get_cvar_num("gundam_radius")
gBright = get_cvar_num("gundam_bright")
get_players(players,pnum,"a")
for(new i = 0; i < pnum; i++) {
idring = players[i]
if (!is_user_alive(idring)) continue
if (!get_user_origin(idring,vec1,0)) continue
for (new j = 0; j < pnum; j++) {
id = players[j]
if (!gHasgundamPower[id]) continue
if (!is_user_alive(id)) continue
if (idring == id) continue
message_begin(MSG_ONE,SVC_TEMPENTITY,vec1,id)
write_byte( 21 )
write_coord(vec1[0])
write_coord(vec1[1])
write_coord(vec1[2] + 16)
write_coord(vec1[0])
write_coord(vec1[1])
write_coord(vec1[2] + gRadius )
write_short( gSpriteWhite )
write_byte( 0 ) // startframe
write_byte( 1 ) // framerate
write_byte( 6 ) // 3 life 2
write_byte( 8 ) // width 16
write_byte( 1 ) // noise
write_byte( 0 ) // r
write_byte( 255 ) // g
write_byte( 0 ) // b
write_byte( gBright ) //brightness
write_byte( 0 ) // speed
message_end()
}
}
}
//----------------------------------------------------------------------------------------------
public make_gundam(id)
{
new weap = read_data(2) // id of the weapon
new ammo = read_data(3) // ammo left in clip
new pteam[16]
new players[32]
new i, n
get_user_team(id, pteam, 15)
if (lastweap[id] == 0) lastweap[id] = weap
if ((lastammo[id] > ammo) && (lastweap[id] == weap)) {
get_players(players, n, "c")
new vec[3]
new aimvec[3]
new velocityvec[3]
new length
new speed = 2400
get_user_origin(id,vec)
get_user_origin(id,aimvec,4)
vec[2] -= 6
velocityvec[0]=aimvec[0]-vec[0]
velocityvec[1]=aimvec[1]-vec[1]
velocityvec[2]=aimvec[2]-vec[2]
length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2])
velocityvec[0]=velocityvec[0]*speed/length
velocityvec[1]=velocityvec[1]*speed/length
velocityvec[2]=velocityvec[2]*speed/length
for(i = 0; i < n; i++)
if ((is_user_connected(players[i])) && (gHasgundamPower[players[i]]==true))
draw_gundam_for(players[i], pteam, vec , velocityvec)
}
lastammo[id] = ammo
lastweap[id] = weap
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public draw_gundam_for(pl, pteam[], vec[3], velocityvec[3])
{
message_begin(MSG_ONE, SVC_TEMPENTITY, vec, pl)
write_byte(TE_USERgundam)
write_coord(vec[0]) // start point
write_coord(vec[1])
write_coord(vec[2])
write_coord(velocityvec[0]) // end point
write_coord(velocityvec[1])
write_coord(velocityvec[2])
write_byte(10)// byte ( life * 10 )
if (equali(pteam,"CT")) write_byte(3); else write_byte(1)
write_byte(15)// byte ( length * 10 )
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public gundam_tasks(id)
{
set_task(1.0, "gundam_morph", id)
if( get_cvar_num("gundam_teamglow") ){
set_task(1.0, "gundam_glow", id+gTaskID, "", 0, "b" )
}
}
//----------------------------------------------------------------------------------------------
public gundam_sound(id)
{
new SND_STOP=(1<<5)
emit_sound(id, CHAN_AUTO, ggundamSound, 0.2, ATTN_NORM, SND_STOP , PITCH_NORM)
emit_sound(id, CHAN_AUTO, ggundamSound, 0.2, ATTN_NORM, 0, PITCH_NORM)
}
//----------------------------------------------------------------------------------------------
public gundam_morph(id)
{
if ( gmorphed[id] || !is_user_alive(id) ) return
#if defined AMXX_VERSION
cs_set_user_model(id, "Gundam")
#else
CS_SetModel(id, "Gundam")
#endif
gundam_sound(id)
// Message
set_hudmessage(50, 205, 50, -1.0, 0.40, 2, 0.02, 4.0, 0.01, 0.1, 7)
show_hudmessage(id, "Strike Gundam - All System Functional")
gmorphed[id] = true
}
//----------------------------------------------------------------------------------------------
public gundam_unmorph(id)
{
if ( gmorphed[id] ) {
// Message
set_hudmessage(50, 205, 50, -1.0, 0.40, 2, 0.02, 4.0, 0.01, 0.1, 7)
show_hudmessage(id, "Strike Gundam -EJECT, All System Down")
#if defined AMXX_VERSION
cs_reset_user_model(id)
#else
CS_ClearModel(id)
#endif
gundam_sound(id)
gmorphed[id] = false
if ( get_cvar_num("gundam_teamglow") ) {
remove_task(id+gTaskID)
set_user_rendering(id)
}
}
}
//----------------------------------------------------------------------------------------------
public gundam_glow(id)
{
id -= gTaskID
if ( !is_user_connected(id) ) {
//Don't want any left over residuals
remove_task(id+gTaskID)
return
}
if ( gHasgundamPower[id] && is_user_alive(id)) {
if ( get_user_team(id) == 1 ) {
shGlow(id, 255, 0, 0)
}
else {
shGlow(id, 0, 0, 255)
}
}
}
//-----------------------------------------------------------------------------------------------------
public newSpawn(id)
{
if ( gHasgundamPower[id] && is_user_alive(id) && shModActive() ) {
set_task(0.1, "gundam_weapons", id)
gundam_tasks(id)
new wpnid = read_data(2)
if (wpnid != CSW_M4A1 && wpnid > 0) {
new wpn[32]
get_weaponname(wpnid,wpn,31)
engclient_cmd(id,wpn)
}
}
}
//----------------------------------------------------------------------------------------------
public gundam_weapons(id)
{
if ( is_user_alive(id) ) {
shGiveWeapon(id,"weapon_m4a1")
}
}
//----------------------------------------------------------------------------------------------
public gundam_death()
{
new id = read_data(2)
gundam_unmorph(id)
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
gmorphed[id] = false
}
//----------------------------------------------------------------------------------------------
public weaponChange(id)
{
if ( !gHasgundamPower[id] || !shModActive() ) return
new wpnid = read_data(2)
new clip = read_data(3)
if ( wpnid != CSW_M4A1 ) return
// Never Run Out of Ammo!
if ( clip == 0 ) {
shReloadAmmo(id)
}
}