Re: My blockmaker...
showLightMenu
public handleLightMenu
lightCreate
lightCreate2
Heres where most of the light info starts
Code:
showLightMenu(id)
{
new col[3];
new szMenu[256];
new szGodmode[6];
new szNoclip[6];
col = (get_user_flags(id) & BM_ADMIN_LEVEL ? "\w" : "\d");
szNoclip = (get_user_noclip(id) ? "\yOn" : "\rOff");
szGodmode = (get_user_godmode(id) ? "\yOn" : "\rOff");
//format the long jump menu
format(szMenu, sizeof(szMenu), gszLightMenu, gLightRadius[id], col, col, col, floatround(gLightR[id]), floatround(gLightG[id]), floatround(gLightB[id]), col, szNoclip, col, szGodmode);
//show the long jump menu to the player
show_menu(id, gKeysLightMenu, szMenu, -1, "bmLightMenu");
}
showColorMenu(id)
{
new col[3];
new szMenu[256];
new szGodmode[6];
new szNoclip[6];
col = (get_user_flags(id) & BM_ADMIN_LEVEL ? "\w" : "\d");
szNoclip = (get_user_noclip(id) ? "\yOn" : "\rOff");
szGodmode = (get_user_godmode(id) ? "\yOn" : "\rOff");
//format the long jump menu
format(szMenu, sizeof(szMenu), gszColorMenu, floatround(gLightR[id]), floatround(gLightG[id]), floatround(gLightB[id]), col, szNoclip, col, szGodmode);
//show the long jump menu to the player
show_menu(id, gKeysColorMenu, szMenu, -1, "bmColorMenu");
}
showOptionsMenu(id, oldMenu)
{
//set the oldmenu global variable so when the back key is pressed it goes back to the previous menu
gMenuBeforeOptions[id] = oldMenu;
new col[3];
new szSnapping[6];
new szMenu[256];
col = (get_user_flags(id) & BM_ADMIN_LEVEL ? "\w" : "\d");
szSnapping = (gbSnapping[id] ? "\yOn" : "\rOff");
//format the options menu
format(szMenu, sizeof(szMenu), gszOptionsMenu, col, szSnapping, col, gfSnappingGap[id], col, col, col, col, col, col, col);
//show the options menu to the player
show_menu(id, gKeysOptionsMenu, szMenu, -1, "bmOptionsMenu");
}
showChoiceMenu(id, gChoice, const szTitle[96])
{
gChoiceOption[id] = gChoice;
//format choice menu using given title
new szMenu[128];
format(szMenu, sizeof(szMenu), gszChoiceMenu, szTitle);
//show the choice menu to the player
show_menu(id, gKeysChoiceMenu, szMenu, -1, "bmChoiceMenu");
}
public handleMainMenu(id, num)
{
switch (num)
{
case N1: { showBlockMenu(id); }
case N2: { showTeleportMenu(id); }
case N3: { showLightMenu(id); }
case N4: { toggleNoclip(id); }
case N5: { toggleGodmode(id); }
case N6: { showOptionsMenu(id, 1); }
case N0: { return; }
}
//selections 1, 2, 3, 4, 5 and 9 show different menus
if (num != N1 && num != N2 && num != N3 && num != N4 && num != N5 && num !=N6)
{
//display menu again
showMainMenu(id);
}
}
public handleBlockMenu(id, num)
{
switch (num)
{
case N1: { showBlockSelectionMenu(id); }
case N2: { createBlockAiming(id, gSelectedBlockType[id]); }
case N3: { convertBlockAiming(id, gSelectedBlockType[id]); }
case N4: { deleteBlockAiming(id); }
case N5: { rotateBlockAiming(id); }
case N6: { toggleNoclip(id); }
case N7: { toggleGodmode(id); }
case N8: { changeBlockSize(id); }
case N9: { showOptionsMenu(id, 2); }
case N0: { showMainMenu(id); }
}
//selections 1, 9 and 0 show different menus
if (num != N1 && num != N9 && num != N0)
{
//display menu again
showBlockMenu(id);
}
}
public handleBlockSelectionMenu(id, num)
{
switch (num)
{
case N9:
{
//goto next block selection menu page
++gBlockMenuPage[id];
//make sure the player can't go above the maximum block selection page
if (gBlockMenuPage[id] > gBlockMenuPagesMax)
{
gBlockMenuPage[id] = gBlockMenuPagesMax;
}
//show block selection menu again
showBlockSelectionMenu(id);
}
case N0:
{
//goto previous block selection menu page
--gBlockMenuPage[id];
//show block menu if player goes back too far
if (gBlockMenuPage[id] < 1)
{
showBlockMenu(id);
gBlockMenuPage[id] = 1;
}
else
{
//show block selection menu again
showBlockSelectionMenu(id);
}
}
default:
{
//offset the num value using the players block selection page number
num += (gBlockMenuPage[id] - 1) * 8;
//if block number is within range
if (num < gBlockMax)
{
gSelectedBlockType[id] = num;
showBlockMenu(id);
}
else
{
showBlockSelectionMenu(id);
}
}
}
}
public handleTeleportMenu(id, num)
{
switch (num)
{
case N1: { createTeleportAiming(id, TELEPORT_START); }
case N2: { createTeleportAiming(id, TELEPORT_END); }
case N3: { swapTeleportAiming(id); }
case N4: { deleteTeleportAiming(id); }
case N5: { showTeleportPath(id); }
case N6: { toggleNoclip(id); }
case N7: { toggleGodmode(id); }
case N9: { showOptionsMenu(id, 3); }
case N0: { showMainMenu(id); }
}
//selections 9 and 0 show different menus
if (num != N9 && num != N0)
{
showTeleportMenu(id);
}
}
lightRadius(id, num)
{
switch (num)
{
case 1:
{
if (gLightRadius[id] < 100) gLightRadius[id]++;
}
case 2:
{
if (gLightRadius[id] > 5) gLightRadius[id]--;
}
default:
{
log_amx("%sInvalid number in lightRadius()", gszPrefix);
}
}
}
lightCreate(const id)
{
new origin[3], Float:vOrigin[3];
//get the origin of the player and add Z offset
get_user_origin(id, origin, 3);
IVecFVec(origin, vOrigin);
vOrigin[2] += floatabs(gfLightSizeMin[2]);
new Float:RenderColor[3];
RenderColor[0] = gLightR[id];
RenderColor[1] = gLightG[id];
RenderColor[2] = gLightB[id];
lightCreate2(vOrigin, RenderColor, gLightRadius[id] );
}
lightCreate2(Float:vOrigin[3], Float:RenderColor[3], radius )
{
new ent = create_entity(gszInfoTarget);
if (is_valid_ent(ent))
{
//set teleport properties
entity_set_string(ent, EV_SZ_classname, gszLightClassname);
entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
entity_set_model(ent, gszLightModel);
entity_set_size(ent, gfLightSizeMin, gfLightSizeMax);
entity_set_origin(ent, vOrigin);
//save the colors
entity_set_vector(ent, EV_VEC_vuser2, RenderColor);
//save the radius
entity_set_int(ent, EV_INT_body, radius);
//set task for light
new parm[5];
parm[0] = ent;
parm[1] = floatround(RenderColor[0]);
parm[2] = floatround(RenderColor[1]);
parm[3] = floatround(RenderColor[2]);
parm[4] = radius;
set_task(1.0, "taskLight", TASK_SPRITE + ent, parm, 5, "b");
}
else
{
log_amx("%sCouldn't create light entity", gszPrefix);
}
}
public handleLightMenu(id, num)
{
switch (num)
{
case N1: { lightRadius(id, 1); }
case N2: { lightCreate(id); }
case N3: { lightRadius(id, 2); }
case N4: { deleteLightAiming(id); }
case N5: { showColorMenu(id); }
case N6: { toggleNoclip(id); }
case N7: { toggleGodmode(id); }
case N9: { showOptionsMenu(id, 7); }
case N0: { showMainMenu(id); }
}
//selections 9 and 0 show different menus
if (num != N5 && num != N9 && num != N0)
{
showLightMenu(id);
}
}
public handleColorMenu(id, num)
{
switch (num)
{
case N1: { gLightR[id] = floatclamp( gLightR[id]+25.5, 0.0, 255.0 ); }
case N2: { gLightR[id] = floatclamp( gLightR[id]-25.5, 0.0, 255.0 ); }
case N3: { gLightG[id] = floatclamp( gLightG[id]+25.5, 0.0, 255.0 ); }
case N4: { gLightG[id] = floatclamp( gLightG[id]-25.5, 0.0, 255.0 ); }
case N5: { gLightB[id] = floatclamp( gLightB[id]+25.5, 0.0, 255.0 ); }
case N6: { gLightB[id] = floatclamp( gLightB[id]-25.5, 0.0, 255.0 ); }
case N7: { toggleNoclip(id); }
case N8: { toggleGodmode(id); }
case N9: { showOptionsMenu(id, 8); }
case N0: { showLightMenu(id); }
}
//selections 9 and 0 show different menus
if (num != N9 && num != N0)
{
showColorMenu(id);
}
}
public handleOptionsMenu(id, num)
{
switch (num)
{
case N1: { toggleSnapping(id); }
case N2: { toggleSnappingGap(id); }
case N3: { groupBlockAiming(id); }
case N4: { groupClear(id); }
case N5: { showChoiceMenu(id, CHOICE_DEL_BLOCKS, "Are you sure you want to erase all blocks on the map?"); }
case N6: { showChoiceMenu(id, CHOICE_DEL_TELEPORTS, "Are you sure you want to erase all teleports on the map?"); }
case N7: { saveBlocks(id); }
case N8: { showChoiceMenu(id, CHOICE_LOAD, "Loading will erase all blocks and teleports, do you want to continue?"); }
case N9: { showChoiceMenu(id, CHOICE_DEL_LIGHTS, "Are you sure you want to erase all lights on the map?"); }
case N0: //back to previous menu
{
switch (gMenuBeforeOptions[id])
{
case 1: showMainMenu(id);
case 2: showBlockMenu(id);
case 3: showTeleportMenu(id);
case 4: showLightMenu(id);
case 5: showColorMenu(id);
//for some reason the players 'gMenuBeforeOptions' number is invalid
default: log_amx("%sPlayer ID: %d has an invalid gMenuBeforeOptions: %d", gszPrefix, id, gMenuBeforeOptions[id]);
}
}
}
//these selections show a different menu
if (num != N5 && num != N6 && num != N8 && num != N9 && num != N0)
{
//display menu again
showOptionsMenu(id, gMenuBeforeOptions[id]);
}
}
public handleChoiceMenu(id, num)
{
switch (num)
{
case N1: //YES
{
switch (gChoiceOption[id])
{
case CHOICE_LOAD: loadBlocks(id);
case CHOICE_DEL_BLOCKS: deleteAllBlocks(id, true);
case CHOICE_DEL_TELEPORTS: deleteAllTeleports(id, true);
case CHOICE_DEL_LIGHTS: deleteAllLights(id, true);
default:
{
log_amx("%sInvalid choice in handleChoiceMenu()", gszPrefix);
}
}
}
}
//show options menu again
showOptionsMenu(id, gMenuBeforeOptions[id]);
|