Quote:
Originally Posted by Depresie
Try this code, tell me if it compiles ( i have cut it from the lighting system i created for my zp server )
PHP Code:
#include <amxmodx> #include <hamsandwich> #include <fakemeta>
// Lighting new cvar_lighting
public plugin_init() { register_plugin("[ZP] New Lighting System", "1.0", "Depresie") // Disable sky lighting so it doesn't mess with our custom lighting set_cvar_num("sv_skycolor_r", 0) set_cvar_num("sv_skycolor_g", 0) set_cvar_num("sv_skycolor_b", 0) cvar_lighting = register_cvar("amx_lighting", "j") }
public plugin_cfg() { set_task(3.0, "lighting_task", _, _, _, "b") }
public lighting_task() { new lighting[2] get_pcvar_string(cvar_lighting, lighting, charsmax(lighting)) // Lighting disabled? ["0"] if (lighting[0] == '0') return;
new Players[32], Num, id get_players(Players, Num, "ach") for(new i = 0; i < Num; i++) { id = Players[i] set_player_light(id, lighting) } }
public set_player_light(id, const LightStyle[]) { if(is_user_connected(id)) {
message_begin(MSG_ONE_UNRELIABLE, SVC_LIGHTSTYLE, _, id) write_byte(0) write_string(LightStyle) message_end() } }
|
Yeah the lights work perfect!
Is the sky supposed to change or are we just testing the lights right now?
Also could you make it to be able to change the lights level via console like this one?
// Set Light Level
//====================
public admin_lights(id,level,cid)
{
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new cmdarg[32]
read_argv(1,cmdarg,31)
if (equal(cmdarg,"off")||equal(cmdarg,"OFF")){
set_lights("#OFF")
set_vaultdata("amx_lights","#OFF")
console_print(id,"[AMXX] Light Returned To Normal.")
}
else{
set_lights(cmdarg)
set_vaultdata("amx_lights",cmdarg)
console_print(id,"[AMXX] Light Change Successful.")
}
return PLUGIN_HANDLED
}