Member
|
08-14-2011
, 11:53
Rendering
|
#1
|
I try to make blockmaker render menu. everything is ok but i can't save renders colors.
i hope anyone help me this is my code.
i don't know how save and load renders
PHP Code:
new g_red[33],g_green[33],g_blue[33],g_alpha[33]; // My colors RGB
PHP Code:
public Render(id){ //Renders Menu
static msg[2500];
new len = formatex(msg, sizeof(msg) - 1, "\r[Renders]^n^n");
len += format(msg[len], sizeof(msg) - len - 1, "\w1.\rMake render^n");
len += format(msg[len], sizeof(msg) - len - 1, "\w2.\rRed:\y%d^n",g_red[id]);
len += format(msg[len], sizeof(msg) - len - 1, "\w3.\rGreen:\y%d^n",g_green[id]);
len += format(msg[len], sizeof(msg) - len - 1, "\w4.\rBlue:\y%d^n",g_blue[id]);
len += format(msg[len], sizeof(msg) - len - 1, "\w5.\rIntensity:\y%d^n^n",g_alpha[id]);
len += format(msg[len], sizeof(msg) - len - 1, "\w6.\rReset value^n");
len += format(msg[len], sizeof(msg) - len - 1, "^n^n\w0.\w Wyjscie");
show_menu(id,RENDER_KEYS, msg, -1,"Render");
return PLUGIN_HANDLED;
}
Keys function
PHP Code:
public KeyRendery(id, key) {
switch(key) {
case 0:{
new body,ent;
get_user_aiming(id, ent, body);
if (IsBlock(ent))
{
set_rendering(ent, kRenderFxGlowShell, g_red[id], g_green[id], g_blue[id], g_alpha[id]);
Render(id);
}
}
case 1:{
if(g_red[id] >= 255) {
BCM_Print(id, "^x03 Maximum^x04 255");
Render(id);
}
else
{
g_red[id] += 5;
Render(id);
}
}
case 2:{
if(g_green[id] >= 255) {
BCM_Print(id, "^x03 Maximum^x04 255");
Render(id);
}
else
{
g_green[id] += 5;
Render(id);
}
}
case 3:{
if(g_blue[id] >= 255) {
BCM_Print(id, "^x03 Maximum^x04 255");
Render(id);
}
else
{
g_blue[id] += 5;
Render(id);
}
}
case 4:{
if(g_alpha[id] >= 255) {
BCM_Print(id, "^x03 Maximum^x04 255");
Render(id);
}
else
{
g_alpha[id] += 5;
Render(id);
}
}
case 5:{
g_alpha[id] = 0;
g_blue[id] = 0;
g_green[id] = 0;
g_red[id] = 0;
Render(id);
}
}
}
Save Blocks
PHP Code:
SaveBlocks(id)
{
if ( !g_admin[id] )
{
console_print(id, "You need acces here");
return PLUGIN_HANDLED;
}
new ent;
new file;
new data[128];
new block_count;
new tele_count;
new light_count;
new block_type;
new size;
new property1[5], property2[5], property3[5], property4[5];
new tele;
new Float:origin[3];
new Float:angles[3];
new Float:tele_start[3];
new Float:tele_end[3];
new Float:max_size;
new Float:size_max[3];
file = fopen(g_file, "wt");
block_count = 0;
tele_count = 0;
ent = -1;
while ( ( ent = find_ent_by_class(ent, g_block_classname) ) )
{
block_type = entity_get_int(ent, EV_INT_body);
entity_get_vector(ent, EV_VEC_origin, origin);
entity_get_vector(ent, EV_VEC_angles, angles);
entity_get_vector(ent, EV_VEC_maxs, size_max);
pev( ent, pev_rendercolor, flRenderColor );
GetProperty(ent, 1, property1);
GetProperty(ent, 2, property2);
GetProperty(ent, 3, property3);
GetProperty(ent, 4, property4);
if ( !property1[0] ) copy(property1, charsmax(property1), "/");
if ( !property2[0] ) copy(property2, charsmax(property2), "/");
if ( !property3[0] ) copy(property3, charsmax(property3), "/");
if ( !property4[0] ) copy(property4, charsmax(property4), "/");
max_size = size_max[0] + size_max[1] + size_max[2];
if ( max_size > 128.0 ) size = LARGE;
else if ( max_size > 64.0 ) size = NORMAL;
else if ( max_size > 32.0 ) size = POLE;
else size = TINY;
formatex(data, charsmax(data), "%c %f %f %f %f %f %f %d %s %s %s %s %d %d %d^n",\
g_block_save_ids[block_type],\
origin[0],\
origin[1],\
origin[2],\
angles[0],\
angles[1],\
angles[2],\
size,\
property1,\
property2,\
property3,\
property4
);
fputs(file, data);
++block_count;
}
ent = -1;
while ( ( ent = find_ent_by_class(ent, g_destination_classname) ) )
{
tele = entity_get_int(ent, EV_INT_iuser1);
if ( tele )
{
entity_get_vector(tele, EV_VEC_origin, tele_start);
entity_get_vector(ent, EV_VEC_origin, tele_end);
formatex(data, charsmax(data), "* %f %f %f %f %f %f^n",\
tele_start[0],\
tele_start[1],\
tele_start[2],\
tele_end[0],\
tele_end[1],\
tele_end[2]
);
fputs(file, data);
++tele_count;
}
}
ent = -1;
while ( ( ent = find_ent_by_class(ent, g_light_classname) ) )
{
entity_get_vector(ent, EV_VEC_origin, origin);
GetProperty(ent, 1, property1);
GetProperty(ent, 2, property2);
GetProperty(ent, 3, property3);
GetProperty(ent, 4, property4);
formatex(data, charsmax(data), "! %f %f %f / / / / %s %s %s %s^n",\
origin[0],\
origin[1],\
origin[2],\
property1,\
property2,\
property3,\
property4
);
fputs(file, data);
++light_count;
}
static name[32];
get_user_name(id, name, charsmax(name));
for ( new i = 1; i <= g_max_players; ++i )
{
if ( g_connected[i]
&& ( g_admin[i] || g_gived_access[i] ) )
{
BCM_Print(i, "^1%s^3Saved^1 %d block^3,^1 %d teleports ^3 i^1 %dlightl^3! Byt on map:^1 %d", name, block_count, tele_count, light_count, entity_count());
}
}
fclose(file);
return PLUGIN_HANDLED;
}
And load blocks
PHP Code:
LoadBlocks(id)
{
if ( id != 0 && !g_admin[id] )
{
console_print(id, "Nie masz dostepu do tej komendy");
return PLUGIN_HANDLED;
}
else if ( !file_exists(g_file)
&& 1 <= id <= g_max_players )
{
BCM_Print(id, "Nie mozna znalezc pliku:^1 %s", g_file);
return PLUGIN_HANDLED;
}
if ( 1 <= id <= g_max_players )
{
DeleteAll(id, false);
}
new file;
new data[128];
new block_count;
new tele_count;
new light_count;
new type[2];
new block_size[17];
new origin_x[17];
new origin_y[17];
new origin_z[17];
new angel_x[17];
new angel_y[17];
new angel_z[17];
new block_type;
new axis;
new size;
new property1[5], property2[5], property3[5], property4[5];
new Float:origin[3];
new Float:angles[3];
file = fopen(g_file, "rt");
block_count = 0;
tele_count = 0;
while ( !feof(file) )
{
type = g_blank;
fgets(file, data, charsmax(data));
parse(data,\
type, charsmax(type),\
origin_x, charsmax(origin_x),\
origin_y, charsmax(origin_y),\
origin_z, charsmax(origin_z),\
angel_x, charsmax(angel_x),\
angel_y, charsmax(angel_y),\
angel_z, charsmax(angel_z),\
block_size, charsmax(block_size),\
property1, charsmax(property1),\
property2, charsmax(property2),\
property3, charsmax(property3),\
property4, charsmax(property4)
);
origin[0] = str_to_float(origin_x);
origin[1] = str_to_float(origin_y);
origin[2] = str_to_float(origin_z);
angles[0] = str_to_float(angel_x);
angles[1] = str_to_float(angel_y);
angles[2] = str_to_float(angel_z);
size = str_to_num(block_size);
if ( strlen(type) > 0 )
{
if ( type[0] != '*' )
{
if ( angles[0] == 90.0 && angles[1] == 0.0 && angles[2] == 0.0 )
{
axis = X;
}
else if ( angles[0] == 90.0 && angles[1] == 0.0 && angles[2] == 90.0 )
{
axis = Y;
}
else
{
axis = Z;
}
}
switch ( type[0] )
{
case 'A': block_type = BUNNYHOP;
case 'B': block_type = NO_SLOW_DOWN_BUNNYHOP;
case 'C': block_type = DELAYED_BUNNYHOP;
case 'D': block_type = DAMAGE;
case 'E': block_type = HEALER;
case 'F': block_type = NO_FALL_DAMAGE;
case 'G': block_type = ICE;
case 'H': block_type = TRAMPOLINE;
case 'I': block_type = SPEED_BOOST;
case 'J': block_type = DEATH;
case 'K': block_type = LOW_GRAVITY;
case 'L': block_type = HONEY;
case 'M': block_type = CT_BARRIER;
case 'N': block_type = T_BARRIER;
case 'O': block_type = GLASS;
case 'P': block_type = PLATFORM;
case 'Q': block_type = TRAWA;
case 'R': block_type = DREWNO;
case 'S': block_type = INVINCIBILITY;
case 'T': block_type = STEALTH;
case 'U': block_type = BOOTS_OF_SPEED;
case 'V': block_type = MONEYBLOCK;
case 'W': block_type = KAMUFLAZ;
case 'X': block_type = MELANZ;
case 'Y': block_type = SG;
case 'Z': block_type = HE;
case '@': block_type = GRANATY;
case '#': block_type = BRON;
case '$': block_type = VIP;
case '%': block_type = DUCK;
case '1': block_type = KOKS;
case '2': block_type = SKY;
case '3': block_type = BHOP2;
case '4': block_type = BHLOD;
case '*':
{
CreateTeleport(0, TELEPORT_START, origin);
CreateTeleport(0, TELEPORT_DESTINATION, angles);
++tele_count;
}
case '!':
{
CreateLight(origin, property1, property2, property3, property4);
++light_count;
}
}
if ( type[0] != '*' && type[0] != '!' )
{
CreateBlock(0, block_type, origin, axis, size, property1, property2, property3, property4);
++block_count;
}
}
}
fclose(file);
if ( 1 <= id <= g_max_players )
{
static name[32];
get_user_name(id, name, charsmax(name));
for ( new i = 1; i <= g_max_players; ++i )
{
if ( !g_connected[i]
|| !g_admin[i] && !g_gived_access[i] ) continue;
BCM_Print(i, "^1%s^3 loaded^1 %d block%s^3,^1 %d teleport%s^3 and^1 %d light%s^3! Total entites in map:^1 %d", name, block_count, block_count == 1 ? g_blank : "s", tele_count, tele_count == 1 ? g_blank : "s", light_count, light_count == 1 ? g_blank : "s", entity_count());
}
}
return PLUGIN_HANDLED;
}
|
|