Witam
Jest to mój pierwszy post w tym dziale, wiec proszę o wyrozumiałość
Krotki wstęp:
Ostatnio miałem problem z szukaniem skryptów do pisania klas, wiec zapisywałem je sobie w jednym miejscu. Tak wyszło sporo dodatkow do klas, które postanowiłem opublikować w całości.
W przyszłości też będę robił podobne tematy
A więc zaczynajmy:
1.Przerabianie klasy na premium:
Biblioteki:
#include <engine>
#include <ColorChat>
Szukamy publica:
public cod_class_enabled(id)
ma_klase[id] = true;
I zmieniamy go na:
public cod_class_enabled(id)
{
ColorChat(id, RED, "^x04Klasa^x03 %s^x04 By^x01 amxx.pl", nazwa); //Gdy gracz nie ma flagi wyświetli mu komunikat
if(!(get_user_flags(id) & ADMIN_LEVEL_H)) //FLAGA
{
ColorChat(id, RED, "^x03[%s]^x04 Jest^x03 klasa premium", nazwa) //Znowu info ze przykładowa klasa jest PREMIUM
return COD_STOP;
}
ma_klase[id] = true;
return COD_CONTINUE;
}
2. Niewidzialność postaci:
Do bibliotek dodajemy:
#include <engine>
Potem w zmiennych:
new ma_klase[33];
i w publikach dodajemy takie cos:
public cod_class_enabled(id)
{
set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 1); ///tu zmieniasz stopien niewidzialnosci
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255);
ma_klase[id] = false;
}
3. Grawitacja:
Biblioteki:
#include <fun>
Zmienne:
new ma_klase[33];
I jak nie mamy tych 2 publicow to dodajemy(a jak mamy to podmieniamy):
public cod_class_enabled(id){
ma_klase[id] = true;
set_user_gravity(id, 0.5)///Tutaj wartość jaką chcecie(1.0 - normalny skok)
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
set_user)gravity(id) = false;
}
4. Multijump:
Biblioteki:
#include <fakemeta>
Zmienne:
new skoki[33];
new ma_klase[33];
Rejestrujemy:
register_forward(FM_CmdStart, "fwCmdStart_MultiJump");
Dodajemy publiki cod_class_enabled/disabled, jesli ich nie macie:
public cod_class_enabled(id)
{
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
}
I na koncu sma:
public fwCmdStart_MultiJump(id, uc_handle)
{
if(!is_user_alive(id) || !ma_klase[id])
return FMRES_IGNORED;
new flags = pev(id, pev_flags);
if((get_uc(uc_handle, UC_Buttons) & IN_JUMP) && !(flags & FL_ONGROUND) && !(pev(id, pev_oldbuttons) & IN_JUMP) && skoki[id])
{
skoki[id]--;
new Float:velocity[3];
pev(id, pev_velocity,velocity);
velocity[2] = random_float(265.0,285.0);
set_pev(id, pev_velocity,velocity);
}
else if(flags & FL_ONGROUND)
skoki[id] = 3;///Tu zmieniamy ilosc skokow
return FMRES_IGNORED;
}
5. BH
Biblioteki:
#include <fakemeta>
Zmienne:
new ma_klase[33];
Rejestrujemy:
register_forward(FM_PlayerPreThink, "fwPrethink_AutoBH");
Jak nie mamy cod_class_enabled_disabled, to dodajemy:
public cod_class_enabled(id)
{
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
}
I na koncu sma:
public fwPrethink_AutoBH(id)
{
if(!ma_klase[id])
return PLUGIN_CONTINUE
if (pev(id, pev_button) & IN_JUMP) {
new flags = pev(id, pev_flags)
if (flags & FL_WATERJUMP)
return FMRES_IGNORED;
if ( pev(id, pev_waterlevel) >= 2 )
return FMRES_IGNORED;
if ( !(flags & FL_ONGROUND) )
return FMRES_IGNORED;
new Float:velocity[3];
pev(id, pev_velocity, velocity);
velocity[2] += 250.0;
set_pev(id, pev_velocity, velocity);
set_pev(id, pev_gaitsequence, 6);
}
return FMRES_IGNORED;
}
6. Cichy bieg:
Rejestrujemy bibliotekę:
#include <fun>
jak przedtem - enabled/disabled
public cod_class_enabled(id){
set_user_footsteps(id, 1);}
{
public cod_class_disabled(id){
set_user_footsteps(id, 0);}
7. Exp za fraga:
Biblioteki:
#include <fun>
Zmienne:
new bool:ma_klase[33];
Rejestrujemy:
register_event("DeathMsg", "Death", "ade");
cod_class_enabled/disabled, tak jak przedtem
I na koncu sma:
public Death(id) //Oto nasz event
{
new attacker = read_data(1);
if(!is_user_connected(attacker))
return PLUGIN_CONTINUE;
if(!ma_klase[attacker])
return PLUGIN_CONTINUE;
if(get_user_team(id) != get_user_team(attacker))
cod_set_user_xp(id, cod_get_user_xp(id)+20); //wartosc 20 zmieniamy (Tyle dodatkowego expa)
return PLUGIN_CONTINUE;
8. Unlimited multijump:
Biblioteki:
#include <fakemeta>
Zmienne:
[sma[new bool:ma_klase[33]
new skoki[33];[/sma]
Rejestrujemy:
register_forward(FM_CmdStart, "fwCmdStart_MultiJump");
cod_class_enabled/disabled:
public cod_class_enabled(id, wartosc)
{
skoki[id] = -1
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
skoki[id] = 0
ma_klase[id] = false;
}
I na koncu sma:
public fwCmdStart_MultiJump(id, uc_handle)
{
if(!is_user_alive(id) || !ma_klase[id])
return FMRES_IGNORED;
new flags = pev(id, pev_flags);
if((get_uc(uc_handle, UC_Buttons) & IN_JUMP) && !(flags & FL_ONGROUND) && !(pev(id, pev_oldbuttons) & IN_JUMP) && skoki[id])
{
skoki[id]--;
new Float:velocity[3];
pev(id, pev_velocity,velocity);
velocity[2] = random_float(265.0,285.0);
set_pev(id, pev_velocity,velocity);
}
else if(flags & FL_ONGROUND)
skoki[id] = -1;
return FMRES_IGNORED;
}
9. Nie zabiera dmg po upadku:
Biblioteki:
#include <engine>
pod includami:
#define FALL_VELOCITY 350.0
Zmienne:
new bool:ma_klase[33];
new bool:falling[33];
cod_class_enabled/disabled jak przedtem
I na koncu sma:
public client_PreThink(id) {
if(ma_klase[id] && is_user_alive(id) && is_user_connected(id))
{
if(entity_get_float(id, EV_FL_flFallVelocity) >= FALL_VELOCITY) {
falling[id] = true;
}
else
{
falling[id] = false;
}
}
}
public client_PostThink(id) {
if(ma_klase[id] && is_user_alive(id) && is_user_connected(id))
{
if(falling[id]) {
entity_set_int(id, EV_INT_watertype, -3);
}
}
10. Niewidzialnosc, gdy sie nie ruszasz:
#include <engine>
#include <fakemeta>
Zmienne:
new ma_klase[33];
W plugin_init:
register_forward(FM_CmdStart, "CmdStart");
Jeśli nie mamy, to dodajemy
public cod_class_enabled(id)
{
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
set_rendering(id,kRenderFxGlowShell,0,0,0 ,kRenderTransAlpha, 255);
}
I na koniec .sma
public CmdStart(id, uc)
{
if(!is_user_alive(id))
return FMRES_IGNORED;
if(ma_perk[id])
{
new Float:fmove, Float:smove;
get_uc(uc, UC_ForwardMove, fmove);
get_uc(uc, UC_SideMove, smove);
if(fmove == 0.0 && smove == 0.0)
set_rendering(id,kRenderFxGlowShell,0,0,0 ,kRenderTransAlpha, 10); // tu ustawiamy niewidke za te 10
else
set_rendering(id,kRenderFxGlowShell,0,0,0 ,kRenderTransAlpha, 255);
}
return FMRES_IGNORED;
}
by sharkowy
11. 1/x na odbicie pocisku:
Biblioteki:
#include <hamsandwich>
Zmienne:
new bool:ma_klase[33];
Rejestrujemy:
RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
enabled/disabled jak przedtem
I na koncu sma:
public TakeDamage(this, idinflictor, idattacker, Float:damage,
damagebits)
{
if(!is_user_connected(idattacker))
return HAM_IGNORED;
if(!ma_klase[this])
return HAM_IGNORED;
if(random(10))//tu zmieniasz 10 (teraz jest 1/10)
return HAM_IGNORED;
cod_inflict_damage(this, idattacker, damage, 0.0, idinflictor,
damagebits);
return HAM_SUPERCEDE;
}
12. Lina spidermana:
Biblioteki:
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <codmod>
#include <xs>
Pod includami:
#define PLUGIN "Spiderman"
#define VERSION "1.0"
#define AUTHOR "RPK. Shark & cypis"///to ich autorstwa
#define message_begin_f(%1,%2,%3,%4) engfunc(EngFunc_MessageBegin,
%1, %2, %3, %4)
#define write_coord_f(%1) engfunc(EngFunc_WriteCoord, %1)
Zmienne:
//Cvars
new pThrowSpeed, pSpeed, pWidth, pSound, pColor
new pInterrupt, pHookSky, pOpenDoors, pPlayers
new pUseButtons, pHostage, pWeapons, pInstant, pHookNoise
// Sprite
new sprBeam
// Players hook entity
new Hook[33]
// MaxPlayers
new gMaxPlayers
// some booleans
new bool:gHooked[33]
new bool:canThrowHook[33]
// Player Spawn
new bool:gRestart[33] = {false, ...}
new bool:gUpdate[33] = {false, ...}
Rejestrujemy:
register_event("HLTV", "round_bstart", "a", "1=0", "2=0")
register_event("TextMsg", "Restart", "a",
"2=#Game_will_restart_in")
register_clcmd("fullupdate", "Update")
register_event("ResetHUD", "ResetHUD", "b")
pThrowSpeed = register_cvar("sv_hookthrowspeed", "1000")
pSpeed = register_cvar("sv_hookspeed", "300")
pWidth = register_cvar("sv_hookwidth", "32")
pSound = register_cvar("sv_hooksound", "1")
pColor = register_cvar("sv_hookcolor", "1")
pPlayers = register_cvar("sv_hookplayers", "0")
pInterrupt = register_cvar("sv_hookinterrupt", "0")
pHookSky = register_cvar("sv_hooksky", "0")
pOpenDoors = register_cvar("sv_hookopendoors", "1")
pUseButtons = register_cvar("sv_hookusebuttons", "1")
pHostage = register_cvar("sv_hookhostflollow", "1")
pWeapons = register_cvar("sv_hookpickweapons", "1")
pInstant = register_cvar("sv_hookinstant", "0")
pHookNoise = register_cvar("sv_hooknoise", "0")
register_forward(FM_Touch, "fwTouch")
gMaxPlayers = get_maxplayers()
Potem publika:
public plugin_precache()
{
// Hook Model
engfunc(EngFunc_PrecacheModel, "models/rpgrocket.mdl")
// Hook Beam
sprBeam = engfunc(EngFunc_PrecacheModel,
"sprites/zbeam4.spr")
// Hook Sounds
engfunc(EngFunc_PrecacheSound, "weapons/xbow_hit1.wav") //
good hit
engfunc(EngFunc_PrecacheSound, "weapons/xbow_hit2.wav") //
wrong hit
engfunc(EngFunc_PrecacheSound, "weapons/xbow_hitbod1.wav")
// player hit
engfunc(EngFunc_PrecacheSound, "weapons/xbow_fire1.wav")
// deploy
}
new ma_klasa[33];
cod_class_enabled/disabled jak przedtem
I na koncu sma:
public client_PreThink(id)
{
if(is_user_alive(id))
{
if(ma_klasa[id])
{
if(pev(id, pev_button) & IN_USE)
{
if(canThrowHook[id] &&
!gHooked[id])
{
throw_hook(id)
}
return PLUGIN_HANDLED
}
else
del_hook(id)
}
}
return PLUGIN_HANDLED
}
public del_hook(id)
{
// Remove players hook
if (!canThrowHook[id])
remove_hook(id)
return PLUGIN_HANDLED
}
public round_bstart()
{
for (new i = 1; i <= gMaxPlayers; i++)
{
if (is_user_connected(i))
{
if(!canThrowHook[i])
remove_hook(i)
}
}
}
public Restart()
{
for (new id = 0; id < gMaxPlayers; id++)
{
if (is_user_connected(id))
gRestart[id] = true
}
}
public Update(id)
{
if (!gUpdate[id])
gUpdate[id] = true
return PLUGIN_CONTINUE
}
public ResetHUD(id)
{
if (gRestart[id])
{
gRestart[id] = false
return
}
if (gUpdate[id])
{
gUpdate[id] = false
return
}
if (gHooked[id])
{
remove_hook(id)
}
}
public fwTouch(ptr, ptd)
{
if (!pev_valid(ptr))
return FMRES_IGNORED
new id = pev(ptr, pev_owner)
// Get classname
static szPtrClass[32]
pev(ptr, pev_classname, szPtrClass, charsmax(szPtrClass))
if (equali(szPtrClass, "Hook"))
{
static Float:fOrigin[3]
pev(ptr, pev_origin, fOrigin)
if (pev_valid(ptd))
{
static szPtdClass[32]
pev(ptd, pev_classname, szPtdClass,
charsmax(szPtdClass))
if (!get_pcvar_num(pPlayers) &&
/*equali(szPtdClass, "player")*/ is_user_alive(ptd))
{
// Hit a player
if (get_pcvar_num(pSound))
emit_sound(ptr,
CHAN_STATIC, "weapons/xbow_hitbod1.wav", 1.0, ATTN_NORM, 0,
PITCH_NORM)
remove_hook(id)
return FMRES_HANDLED
}
else if (equali(szPtdClass,
"hostage_entity"))
{
// Makes an hostage follow
if (get_pcvar_num(pHostage) &&
get_user_team(id) == 2)
{
//cs_set_hostage_foll(ptd,
(cs_get_hostage_foll(ptd) == id) ? 0 : id)
// With the use function
we have the sounds!
dllfunc(DLLFunc_Use, ptd,
id)
}
if (!get_pcvar_num(pPlayers))
{
if(get_pcvar_num(pSound))
emit_sound(ptr,
CHAN_STATIC, "weapons/xbow_hitbod1.wav", 1.0, ATTN_NORM, 0,
PITCH_NORM)
remove_hook(id)
}
return FMRES_HANDLED
}
else if (get_pcvar_num(pOpenDoors) &&
equali(szPtdClass, "func_door") || equali(szPtdClass,
"func_door_rotating"))
{
// Open doors
// Double doors tested in de_nuke
and de_wallmart
static szTargetName[32]
pev(ptd, pev_targetname,
szTargetName, charsmax(szTargetName))
if (strlen(szTargetName) > 0)
{
static ent
while ((ent =
engfunc(EngFunc_FindEntityByString, ent, "target", szTargetName))
> 0)
{
static
szEntClass[32]
pev(ent,
pev_classname, szEntClass, charsmax(szEntClass))
if
(equali(szEntClass, "trigger_multiple"))
{
dllfunc(DLLFunc_Touch, ent, id)
goto
stopdoors // No need to touch anymore
}
}
}
// No double doors.. just touch it
dllfunc(DLLFunc_Touch, ptd, id)
stopdoors:
}
else if (get_pcvar_num(pUseButtons) &&
equali(szPtdClass, "func_button"))
{
if (pev(ptd, pev_spawnflags) &
SF_BUTTON_TOUCH_ONLY)
dllfunc(DLLFunc_Touch,
ptd, id) // Touch only
else
dllfunc(DLLFunc_Use, ptd,
id) // Use Buttons
}
}
// If cvar sv_hooksky is 0 and hook is in the sky
remove it!
new iContents = engfunc(EngFunc_PointContents,
fOrigin)
if (!get_pcvar_num(pHookSky) && iContents ==
CONTENTS_SKY)
{
if(get_pcvar_num(pSound))
emit_sound(ptr, CHAN_STATIC,
"weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_hook(id)
return FMRES_HANDLED
}
// Pick up weapons..
if (get_pcvar_num(pWeapons))
{
static ent
while ((ent =
engfunc(EngFunc_FindEntityInSphere, ent, fOrigin, 15.0)) > 0)
{
static szentClass[32]
pev(ent, pev_classname,
szentClass, charsmax(szentClass))
if (equali(szentClass,
"weaponbox") || equali(szentClass, "armoury_entity"))
dllfunc(DLLFunc_Touch,
ent, id)
}
}
// Player is now hooked
gHooked[id] = true
// Play sound
if (get_pcvar_num(pSound))
emit_sound(ptr, CHAN_STATIC,
"weapons/xbow_hit1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
// Make some sparks :D
message_begin_f(MSG_BROADCAST, SVC_TEMPENTITY,
fOrigin, 0)
write_byte(9) // TE_SPARKS
write_coord_f(fOrigin[0]) // Origin
write_coord_f(fOrigin[1])
write_coord_f(fOrigin[2])
message_end()
// Stop the hook from moving
set_pev(ptr, pev_velocity, Float:{0.0, 0.0, 0.0})
set_pev(ptr, pev_movetype, MOVETYPE_NONE)
//Task
if (!task_exists(id + 856))
{
static TaskData[2]
TaskData[0] = id
TaskData[1] = ptr
gotohook(TaskData)
set_task(0.1, "gotohook", id + 856,
TaskData, 2, "b")
}
}
return FMRES_HANDLED
}
public hookthink(param[])
{
new id = param[0]
new HookEnt = param[1]
if (!is_user_alive(id) || !pev_valid(HookEnt) ||
!pev_valid(id))
{
remove_task(id + 890)
return PLUGIN_HANDLED
}
static Float:entOrigin[3]
pev(HookEnt, pev_origin, entOrigin)
// If user is behind a box or something.. remove it
// only works if sv_interrupt 1 or higher is
if (get_pcvar_num(pInterrupt))
{
static Float:usrOrigin[3]
pev(id, pev_origin, usrOrigin)
static tr
engfunc(EngFunc_TraceLine, usrOrigin, entOrigin,
1, -1, tr)
static Float:fFraction
get_tr2(tr, TR_flFraction, fFraction)
if (fFraction != 1.0)
remove_hook(id)
}
// If cvar sv_hooksky is 0 and hook is in the sky remove
it!
new iContents = engfunc(EngFunc_PointContents, entOrigin)
if (!get_pcvar_num(pHookSky) && iContents == CONTENTS_SKY)
{
if(get_pcvar_num(pSound))
emit_sound(HookEnt, CHAN_STATIC,
"weapons/xbow_hit2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_hook(id)
}
return PLUGIN_HANDLED
}
public gotohook(param[])
{
new id = param[0]
new HookEnt = param[1]
if (!is_user_alive(id) || !pev_valid(HookEnt) ||
!pev_valid(id))
{
remove_task(id + 856)
return PLUGIN_HANDLED
}
// If the round isnt started velocity is just 0
static Float:fVelocity[3]
fVelocity = Float:{0.0, 0.0, 1.0}
// If the round is started and player is hooked we can set
the user velocity!
if (gHooked[id])
{
static Float:fHookOrigin[3], Float:fUsrOrigin[3],
Float:fDist
pev(HookEnt, pev_origin, fHookOrigin)
pev(id, pev_origin, fUsrOrigin)
fDist = vector_distance(fHookOrigin, fUsrOrigin)
if (fDist >= 30.0)
{
new Float:fSpeed = get_pcvar_float(pSpeed)
fSpeed *= 0.52
fVelocity[0] = (fHookOrigin[0] -
fUsrOrigin[0]) * (2.0 * fSpeed) / fDist
fVelocity[1] = (fHookOrigin[1] -
fUsrOrigin[1]) * (2.0 * fSpeed) / fDist
fVelocity[2] = (fHookOrigin[2] -
fUsrOrigin[2]) * (2.0 * fSpeed) / fDist
}
}
// Set the velocity
set_pev(id, pev_velocity, fVelocity)
return PLUGIN_HANDLED
}
public throw_hook(id)
{
// Get origin and angle for the hook
static Float:fOrigin[3], Float:fAngle[3],Float:fvAngle[3]
static Float:fStart[3]
pev(id, pev_origin, fOrigin)
pev(id, pev_angles, fAngle)
pev(id, pev_v_angle, fvAngle)
if (get_pcvar_num(pInstant))
{
get_user_hitpoint(id, fStart)
if (engfunc(EngFunc_PointContents, fStart) !=
CONTENTS_SKY)
{
static Float:fSize[3]
pev(id, pev_size, fSize)
fOrigin[0] = fStart[0] +
floatcos(fvAngle[1], degrees) * (-10.0 + fSize[0])
fOrigin[1] = fStart[1] +
floatsin(fvAngle[1], degrees) * (-10.0 + fSize[1])
fOrigin[2] = fStart[2]
}
else
xs_vec_copy(fStart, fOrigin)
}
// Make the hook!
Hook[id] = engfunc(EngFunc_CreateNamedEntity,
engfunc(EngFunc_AllocString, "info_target"))
if (Hook[id])
{
// Player cant throw hook now
canThrowHook[id] = false
static const Float:fMins[3] = {-2.840000,
-14.180000, -2.840000}
static const Float:fMaxs[3] = {2.840000, 0.020000,
2.840000}
//Set some Data
set_pev(Hook[id], pev_classname, "Hook")
engfunc(EngFunc_SetModel, Hook[id],
"models/rpgrocket.mdl")
engfunc(EngFunc_SetOrigin, Hook[id], fOrigin)
engfunc(EngFunc_SetSize, Hook[id], fMins, fMaxs)
//set_pev(Hook[id], pev_mins, fMins)
//set_pev(Hook[id], pev_maxs, fMaxs)
set_pev(Hook[id], pev_angles, fAngle)
set_pev(Hook[id], pev_solid, 2)
set_pev(Hook[id], pev_movetype, 5)
set_pev(Hook[id], pev_owner, id)
//Set hook velocity
static Float:fForward[3], Float:Velocity[3]
new Float:fSpeed = get_pcvar_float(pThrowSpeed)
engfunc(EngFunc_MakeVectors, fvAngle)
global_get(glb_v_forward, fForward)
Velocity[0] = fForward[0] * fSpeed
Velocity[1] = fForward[1] * fSpeed
Velocity[2] = fForward[2] * fSpeed
set_pev(Hook[id], pev_velocity, Velocity)
// Make the line between Hook and Player
message_begin_f(MSG_BROADCAST, SVC_TEMPENTITY,
Float:{0.0, 0.0, 0.0}, 0)
if (get_pcvar_num(pInstant))
{
write_byte(1) // TE_BEAMPOINT
write_short(id) // Startent
write_coord_f(fStart[0]) // End pos
write_coord_f(fStart[1])
write_coord_f(fStart[2])
}
else
{
write_byte(8) // TE_BEAMENTS
write_short(id) // Start Ent
write_short(Hook[id]) // End Ent
}
write_short(sprBeam) // Sprite
write_byte(1) // StartFrame
write_byte(1) // FrameRate
write_byte(600) // Life
write_byte(get_pcvar_num(pWidth)) // Width
write_byte(get_pcvar_num(pHookNoise)) // Noise
// Colors now
if (get_pcvar_num(pColor))
{
if (get_user_team(id) == 1) // Terrorist
{
write_byte(255) // R
write_byte(0) // G
write_byte(0) // B
}
#if defined _cstrike_included
else if(cs_get_user_vip(id)) // vip for
cstrike
{
write_byte(0) // R
write_byte(255) // G
write_byte(0) // B
}
#endif // _cstrike_included
else if(get_user_team(id) == 2) // CT
{
write_byte(0) // R
write_byte(0) // G
write_byte(255) // B
}
else
{
write_byte(255) // R
write_byte(255) // G
write_byte(255) // B
}
}
else
{
write_byte(255) // R
write_byte(255) // G
write_byte(255) // B
}
write_byte(192) // Brightness
write_byte(0) // Scroll speed
message_end()
if (get_pcvar_num(pSound) &&
!get_pcvar_num(pInstant))
emit_sound(id, CHAN_BODY,
"weapons/xbow_fire1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_HIGH)
static TaskData[2]
TaskData[0] = id
TaskData[1] = Hook[id]
set_task(0.1, "hookthink", id + 890, TaskData, 2,
"b")
}
else
client_print(id, print_chat, "Can't create hook")
}
public remove_hook(id)
{
//Player can now throw hooks
canThrowHook[id] = true
// Remove the hook if it is valid
if (pev_valid(Hook[id]))
engfunc(EngFunc_RemoveEntity, Hook[id])
Hook[id] = 0
// Remove the line between user and hook
if (is_user_connected(id))
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY,
{0,0,0}, id)
write_byte(99) // TE_KILLBEAM
write_short(id) // entity
message_end()
}
// Player is not hooked anymore
gHooked[id] = false
return 1
}
// Stock by Chaosphere
stock get_user_hitpoint(id, Float:hOrigin[3])
{
if (!is_user_alive(id))
return 0
static Float:fOrigin[3], Float:fvAngle[3],
Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3]
static Float:fTemp[3]
pev(id, pev_origin, fOrigin)
pev(id, pev_v_angle, fvAngle)
pev(id, pev_view_ofs, fvOffset)
xs_vec_add(fOrigin, fvOffset, fvOrigin)
engfunc(EngFunc_AngleVectors, fvAngle, feOrigin, fTemp,
fTemp)
xs_vec_mul_scalar(feOrigin, 8192.0, feOrigin)
xs_vec_add(fvOrigin, feOrigin, feOrigin)
static tr
engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id, tr)
get_tr2(tr, TR_vecEndPos, hOrigin)
//global_get(glb_trace_endpos, hOrigin)
return 1
}
stock statusMsg(id, szMsg[], {Float,_}:...)
{
static iStatusText
if (!iStatusText)
iStatusText = get_user_msgid("StatusText")
static szBuffer[512]
vformat(szBuffer, charsmax(szBuffer), szMsg, 3)
message_begin((id == 0) ? MSG_ALL : MSG_ONE, iStatusText,
_, id)
write_byte(0) // Unknown
write_string(szBuffer) // Message
message_end()
return 1
}
13. Dodatkowe dmg:
Biblioteki:
#include <hamsandwich>
Pod includami:
#define DMG_BULLET (1<<1)
Rejestrujemy:
RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
I na koncu sma:
public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
if(!is_user_connected(idattacker))
return HAM_IGNORED;
if(!ma_klase[idattacker])
return HAM_IGNORED;
if(get_user_team(this) != get_user_team(idattacker) && get_user_weapon(idattacker) == CSW_AK47 && damagebits & DMG_BULLET)
cod_inflict_damage(idattacker, this, 5.0, 0.0, idinflictor, damagebits);
return HAM_IGNORED;
}
CSW_AK47 - tutaj sobie zmieniamy na jaką broń chcemy
cod_inflict_damage(idattacker, this, 5.0, 0.0, idinflictor, damagebits);
Wartość 5.0 to dodatkowe dmg, a 0.0 to współczynnik inteligencji. Przykład: Współczynnik = 0.5 - 2int = 1dmg
14. 1/x z wybranej broni:
Biblioteki:
#include <hamsandwich>
Pod includami:
#define DMG_BULLET (1<<1)
Rejestrujemy:
RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
I na koniec sma:
public TakeDamage(this, idinflictor, idattacker, Float:damage,
damagebits)
{
if(!is_user_connected(idattacker))
return HAM_IGNORED;
if(!ma_klase[idattacker])
return HAM_IGNORED;
if(damagebits & DMG_BULLET)
{
new weapon = get_user_weapon(idattacker);
if(weapon == CSW_BRON && damage > 20.0 &&
random_num(1,2) == 1)
cod_inflict_damage(idattacker, this,
float(get_user_health(this))-damage+1.0, 0.0, idinflictor,
damagebits);
}
return HAM_IGNORED;
}
CSW_BRON zmieniasz na twoja np. CSW_AK47
A szansa na zabicie (1,2) tutaj zmieniamy 2 (Teraz jest 1/2)
15. Teleport:
Biblioteki:
#include <fakemeta>
#include <xs>
Zmienne:
new bool:uzyl[33];
Rejestrujemy:
register_event("ResetHUD", "ResetHUD", "abe");
cod_class_enabled:
uzyl[id] = false;
return COD_CONTINUE;
I na koncu sma:
public cod_class_skill_used(id)
{
if (!uzyl[id]==false)
{
client_print(id, print_center, "Teleport mozna uzywac co 20s");
return PLUGIN_CONTINUE;
}
if(uzyl[id] || !is_user_alive(id))
return PLUGIN_CONTINUE;
new Float:start[3], Float:view_ofs[3];
pev(id, pev_origin, start);
pev(id, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);
new Float:dest[3];
pev(id, pev_v_angle, dest);
engfunc(EngFunc_MakeVectors, dest);
global_get(glb_v_forward, dest);
xs_vec_mul_scalar(dest, 999.0, dest);
xs_vec_add(start, dest, dest);
engfunc(EngFunc_TraceLine, start, dest, 0, id, 0);
new Float:fDstOrigin[3];
get_tr2(0, TR_vecEndPos, fDstOrigin);
if(engfunc(EngFunc_PointContents, fDstOrigin) == CONTENTS_SKY)
return PLUGIN_CONTINUE;
new Float:fNormal[3];
get_tr2(0, TR_vecPlaneNormal, fNormal);
xs_vec_mul_scalar(fNormal, 50.0, fNormal);
xs_vec_add(fDstOrigin, fNormal, fDstOrigin);
set_pev(id, pev_origin, fDstOrigin);
uzyl[id] = true;
set_task ( 20.0, "ResetHUD", id )///Tu zmieniamy co ile teleport
set_task ( 10.0, "InfoTel", id )
}
public ResetHUD(id)
{
uzyl[id] = false;
}
public InfoTel(id)
{
client_print(id, print_center, "Ok, teleportuj sie :)");
}
Radar (Widzisz wrogow):
Zmienne:
new g_msgHostageAdd, g_msgHostageDel;
new bool:ma_klase[33]
Rejestrujemy:
g_msgHostageAdd = get_user_msgid("HostagePos");
g_msgHostageDel = get_user_msgid("HostageK");
set_task (2.0,"radar_scan",_,_,_,"b");
I na koncu sma:
public radar_scan(id)
{
new PlayerCoords[3];
for (new id=1; id<=32; id++)
{
if((!is_user_alive(id))||(!ma_klase[id])) continue;
for (new i=1;i<=32;i++)
{
if(!is_user_alive(i) || get_user_team(i) == get_user_team(id))
continue;
get_user_origin(i, PlayerCoords)
message_begin(MSG_ONE_UNRELIABLE, g_msgHostageAdd, {0,0,0}, id)
write_byte(id)
write_byte(i)
write_coord(PlayerCoords[0])
write_coord(PlayerCoords[1])
write_coord(PlayerCoords[2])
message_end()
message_begin(MSG_ONE_UNRELIABLE, g_msgHostageDel, {0,0,0}, id)
write_byte(i)
message_end()
}
}
}
16. Model gracza w zaleznosci od teamu
Rejestrujemy:
RegisterHam(Ham_Spawn, "player", "Odrodzenie", 1);
na koncu sma:
public Odrodzenie(id)
if(get_user_team(id) == 1)
{
//MODEL DLA TT (Tu podajemy sciezke)
}
else if(get_user_team(id) == 2)
{
//MODEL DLA CT (Tu tez)
}
17. Zmiana stroju CT/TT z broniami:
Zmienne:
new Ubrania_CT[4][]={"sas","gsg9","urban","gign"};
new Ubrania_Terro[4][]={"arctic","leet","guerilla","terror"};
Rejestrujemy:
register_event("CurWeapon","CurWeapon","be", "1=1");
Na koncu sma:
public CurWeapon(id)
{
new weapon = read_data(2);
new num = random_num(0,3);
if(ma_klase[id] && weapon == CSW_M4A1)
{
cs_set_user_model(id, Ubrania_CT[num]);
}
if(ma_klase[id] && weapon == CSW_AK47)
{
cs_set_user_model(id, Ubrania_Terro[num]);
}
return PLUGIN_CONTINUE;
}
M4A1 to bron CT, a AK47 to bron TT i możemy sobie pozmieniać jak chcemy
18. No-Recoil
#include <fakemeta>
Zmienne:
new ma_klase[33];
W plugin_init() rejestrujemy:
register_forward(FM_PlayerPreThink, "PreThink");
register_forward(FM_UpdateClientData, "UpdateClientData", 1)
Jeśli nie mamy, to dodajemy:
public cod_class_enabled(id)
{
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
}
I na koniec .sma:
public PreThink(id)
{
if(ma_klase[id])
set_pev(id, pev_punchangle, {0.0,0.0,0.0})
}
public UpdateClientData(id, sw, cd_handle)
{
if(ma_klase[id])
set_cd(cd_handle, CD_PunchAngle, {0.0,0.0,0.0})
}
19. Szansa na pojawienie się u wroga
#include <hamsandwich>
#include <cstrike>
Zmienne:
new ma_klase[33];
W plugin_init() rejestrujemy:
RegisterHam(Ham_Spawn, "player", "Spawn", 1);
Jeśli nie mamy, to dodajemy:
public cod_class_enabled(id)
{
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
}
I na koniec .sma
public Spawn(id)
{
if(!is_user_alive(id))
return;
if(!ma_klase[id])
return;
if(random_num(1,5) == 1)
{
new CsTeams:team = cs_get_user_team(id);
cs_set_user_team(id, (team == CS_TEAM_CT)? CS_TEAM_T: CS_TEAM_CT);
ExecuteHam(Ham_CS_RoundRespawn, id);
cs_set_user_team(id, team);
}
}
20. Ubranie Wroga
#include <cstrike>
Zmienne:
new bool: ma_klase[33];
new CT_Skins[4][] = {"sas","gsg9","urban","gign"};
new Terro_Skins[4][] = {"arctic","leet","guerilla","terror"};
codclass_enabled/disabled:
public cod_class_enabled(id)
{
ZmienUbranie(id, 0);
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ZmienUbranie(id, 1);
ma_klase[id] = false;
}
Na koniec:
public ZmienUbranie(id,reset)
{
if (!is_user_connected(id))
return PLUGIN_CONTINUE;
if (reset)
cs_reset_user_model(id);
else
{
new num = random_num(0,3);
cs_set_user_model(id, (get_user_team(id) == 1)? CT_Skins[num]: Terro_Skins[num]);
}
return PLUGIN_CONTINUE;
}
21. Widzisz wrogów na radarze
#include <engine>
Zmienne:
new ma_klase[33];
new g_msgHostageAdd, g_msgHostageDel;
W plugin_init() rejestrujemy:
g_msgHostageAdd = get_user_msgid("HostagePos");
g_msgHostageDel = get_user_msgid("HostageK");
set_task (2.0,"radar_scan",_,_,_,"b");
Jeśli nie mamy, to dodajemy:
public cod_class_enabled(id)
{
ma_klase[id] = true;
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
}
I na koniec .sma:
public radar_scan(id)
{
new PlayerCoords[3];
for (new id=1; id<=32; id++)
{
if((!is_user_alive(id))||(!ma_klase[id])) continue;
for (new i=1;i<=32;i++)
{
if(!is_user_alive(i) || get_user_team(i) == get_user_team(id)) continue;
get_user_origin(i, PlayerCoords)
message_begin(MSG_ONE_UNRELIABLE, g_msgHostageAdd, {0,0,0}, id)
write_byte(id)
write_byte(i)
write_coord(PlayerCoords[0])
write_coord(PlayerCoords[1])
write_coord(PlayerCoords[2])
message_end()
message_begin(MSG_ONE_UNRELIABLE, g_msgHostageDel, {0,0,0}, id)
write_byte(i)
message_end()
}
}
}
22. Klasa od poziomu
Zmienna: i cod_class_enabled/disabled { public cod_class_disabled(id) W miejsce xx wpisujemy lvl od którego klasa ma być dostępna
new ma_klase[33];
public cod_class_enabled(id)
new dostepna = xx;
new level = cod_get_user_level(id);
if(level < dostepna)
{
client_print(id, print_chat, "[%s]Klasa dostepna od %i poziomu.", nazwa, dostepna)
return COD_STOP;
}
ma_klase[id] = true;
client_print(id, print_chat, "Wybrales klase %s", nazwa)
return COD_CONTINUE;
}
{
ma_klase[id] = false;
}
23. Nieśmiertelność
#include <fun>
Stałe: Zmienne: new bool:ma_klase[33]; Rejestrujemy: register_event("ResetHUD", "ResetHUD", "abe");
Dodajemy: { I na koniec .sma: {
#include <ColorChat>
#define CZAS_GODMOD 5 //ILE SEKUND MA TRWAC NIESMIERTELNOSC
new bool:wykorzystal[33];
new msg_bartime;
msg_bartime = get_user_msgid("BarTime");
public cod_class_enabled(id)
ma_klase[id] = true;
ResetHUD(id);
}
public cod_class_disabled(id)
{
ma_klase[id] = false;
}
public cod_class_skill_used(id)
if(!is_user_alive(id))
return;
if(wykorzystal[id])
{
ColorChat(id, RED, "Wykorzystales juz swoja niesmiertelnosc.");
return;
}
wykorzystal[id] = true;
set_user_godmode(id, 1);
set_user_rendering(id, kRenderFxGlowShell, 255, 0, 0);
set_task(CZAS_GODMOD.0, "WylaczGod", id);
message_begin(MSG_ONE, msg_bartime, _, id)
write_short(CZAS_GODMOD)
message_end()
}
public WylaczGod(id)
{
if(!is_user_connected(id)) return;
set_user_godmode(id, 0);
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0);
}
public ResetHUD(id)
{
wykorzystal[id] = false;
}