AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   doesnt set render after loading blocks (blockmaker) (https://forums.alliedmods.net/showthread.php?t=92059)

zacky 05-09-2009 14:20

doesnt set render after loading blocks (blockmaker)
 
Hi, i have my own blockmaker, and me and xPaw just made our own Render Menu, to add like glowings, transalpha to blocks, saving work just fine, but when it loads the blocks dont get their rendering.

This works in xPaw's blockmaker but not my, so i posted here to get help

Anyway, heres save/load functions

PHP Code:

/***** FILE HANDLING *****/
saveBlocks(id)
{
    
//make sure player has access to this command
    
if (get_user_flags(id) & BM_ADMIN_LEVEL)
    {
        new 
file fopen(gszNewFile"wt");
        new 
ent = -1;
        new 
blockType;
        new 
Float:vOrigin[3];
        new 
Float:vAngles[3];
        new 
Float:vStart[3];
        new 
Float:vEnd[3];
        new 
blockCount 0;
        new 
teleCount 0;
        new 
szData[512];
        new 
Float:fMax;
        new 
size;
        new 
Float:vSizeMax[3];
        new 
szNameCreator[32];
        new 
Float:flRenderColor], Float:flRenderAmtiRenderFXiRenderMode;
        
        while ((
ent find_ent_by_class(entgszBlockClassname)))
        {
            
//get block info
            
blockType pev(entpev_body);
            
pev(entpev_targetnameszNameCreator31);
            
            if( 
blockType == BM_MAGICCARPET )
                
pev(entpev_v_anglevOrigin);
            else
                
pev(entpev_originvOrigin);
            
pev(entpev_anglesvAngles);
            
pev(entpev_maxsvSizeMax);
            
            
size SMALL;
            
fMax vSizeMax[0] + vSizeMax[1] + vSizeMax[2];
            if (
fMax 34.0size POLE;
            if (
fMax 64.0size NORMAL;
            if (
fMax 128.0size LARGE;
            
            
iRenderFX    peventpev_renderfx );
            
iRenderMode    peventpev_rendermode );
            
peventpev_rendercolorflRenderColor );
            
peventpev_renderamtflRenderAmt );
            
            
//format block info and save it to file
            
formatex(szData511"%c %f %f %f %f %f %f %d %s %i %i %f %f %f %f^n"gBlockSaveIds[blockType], vOrigin[0], vOrigin[1], vOrigin[2], vAngles[0], vAngles[1], vAngles[2], sizeszNameCreatoriRenderFXiRenderModeflRenderAmtflRenderColor[0], flRenderColor[1], flRenderColor[2]);
            
fputs(fileszData);
            
            
//increment block count
            
++blockCount;
        }
        
        
//iterate through teleport end entities because you can't have an end without a start
        
ent = -1;
        
        while ((
ent find_ent_by_class(entgszTeleportEndClassname)))
        {
            
//get the id of the start of the teleporter
            
new tele entity_get_int(entEV_INT_iuser1);
            
            
//check that start of teleport is a valid entity
            
if (tele)
            {
                
//get the origin of the start of the teleport and save it to file
                
entity_get_vector(teleEV_VEC_originvStart);
                
entity_get_vector(entEV_VEC_originvEnd);
                
                
//get creator
                
pev(telepev_targetnameszNameCreator31);
                
                
formatex(szData128"%c %f %f %f %f %f %f 0 %s^n"gTeleportSaveIdvStart[0], vStart[1], vStart[2], vEnd[0], vEnd[1], vEnd[2], szNameCreator);
                
fputs(fileszData);
                
                
//2 teleport entities count as 1 teleporter
                
++teleCount;
            }
        }
        
        
//get players name
        
new szName[32];
        
get_user_name(idszName32);
        
        
//notify all admins that the player saved blocks to file
        
for (new 1<= 32; ++i)
        {
            
//make sure player is connected
            
if (is_user_connected(i))
            {
                if (
get_user_flags(i) & BM_ADMIN_LEVEL)
                {
                    
client_print(iprint_chat"%s'%s' saved %d block%s and %d teleporter%s! Total entites in map: %d"gszPrefixszNameblockCount, (blockCount == "" "s"), teleCount, (teleCount == "" "s"), entity_count());
                }
            }
        }
        
        
//close file
        
fclose(file);
    }
}

loadBlocks(id)
{
    new 
bool:bAccess false;
    
    
//if this function was called on map load, ID is 0
    
if (id == 0)
    {
        
bAccess true;
    }
    
//make sure user calling this function has access
    
else if (get_user_flags(id) & BM_ADMIN_LEVEL)
    {
        
bAccess true;
    }
    
    if (
bAccess)
    {
        
//if map file exists
        
if (file_exists(gszNewFile))
        {
            
//if a player is loading then first delete all the old blocks, teleports and timers
            
if (id && id <= 32)
            {
                
deleteAllBlocks(idfalse);
                
deleteAllTeleports(idfalse);
            }
            
            new 
szData[512];
            new 
szType[2];
            new 
sz1[16], sz2[16], sz3[16], sz4[16], sz5[16], sz6[16], sz7[16];
            new 
Float:vVec1[3];
            new 
Float:vVec2[3];
            new 
axis;
            new 
size;
            new 
fopen(gszNewFile"rt");
            new 
blockCount 0;
            new 
teleCount 0;
            new 
szCreator[32];
            new 
szRenderColor[3][16], szRenderFX[3], szRenderMode[3], szRenderAmt[16];
            new 
Float:flRenderColor], Float:flRenderAmtiRenderFXiRenderMode;
            new 
iCreatedEntity;
            
            
//iterate through all the lines in the file
            
while (!feof(f))
            {
                
szType "";
                
fgets(fszData511);
                
parse(szDataszType1sz116sz216sz316sz416sz516sz616sz716szCreator31szRenderFX2szRenderMode2szRenderAmt16szRenderColor[0], 16szRenderColor[1], 16szRenderColor[2], 16);
                
                
vVec1[0] = str_to_float(sz1);
                
vVec1[1] = str_to_float(sz2);
                
vVec1[2] = str_to_float(sz3);
                
vVec2[0] = str_to_float(sz4);
                
vVec2[1] = str_to_float(sz5);
                
vVec2[2] = str_to_float(sz6);
                
size str_to_num(sz7);
                
                
flRenderColor[0] = str_to_floatszRenderColor[0] );
                
flRenderColor[1] = str_to_floatszRenderColor[1] );
                
flRenderColor[2] = str_to_floatszRenderColor[2] );
                
flRenderAmt str_to_floatszRenderAmt );
                
                
iRenderFX str_to_numszRenderFX );
                
iRenderMode str_to_numszRenderMode );
                
                if (
strlen(szType) > 0)
                {
                    
//if type is not a teleport
                    
if (szType[0] != gTeleportSaveId)
                    {
                        
//set axis orientation depending on block angles
                        
if (vVec2[0] == 90.0 && vVec2[1] == 0.0 && vVec2[2] == 0.0)
                        {
                            
axis X;
                        }
                        else if (
vVec2[0] == 90.0 && vVec2[1] == 0.0 && vVec2[2] == 90.0)
                        {
                            
axis Y;
                        }
                        else
                        {
                            
axis Z;
                        }
                        
                        
//increment block counter
                        
++blockCount;
                    }
                    
                    
//create block or teleport depending on type
                    
switch (szType[0])
                    {
                        case 
'A'iCreatedEntity createBlock(0BM_PLATFORMvVec1axissizeszCreator);
                        case 
'B'iCreatedEntity createBlock(0BM_BHOPvVec1axissizeszCreator);
                        case 
'C'iCreatedEntity createBlock(0BM_DAMAGEvVec1axissizeszCreator);
                        case 
'D'iCreatedEntity createBlock(0BM_HEALERvVec1axissizeszCreator);
                        case 
'E'iCreatedEntity createBlock(0BM_INVINCIBILITYvVec1axissizeszCreator);
                        case 
'F'iCreatedEntity createBlock(0BM_STEALTHvVec1axissizeszCreator);
                        case 
'G'iCreatedEntity createBlock(0BM_TRAMPOLINEvVec1axissizeszCreator);
                        case 
'H'iCreatedEntity createBlock(0BM_SPEEDBOOSTvVec1axissizeszCreator);
                        case 
'I'iCreatedEntity createBlock(0BM_NOFALLDAMAGEvVec1axissizeszCreator);
                        case 
'J'iCreatedEntity createBlock(0BM_ICEvVec1axissizeszCreator);
                        case 
'K'iCreatedEntity createBlock(0BM_DEATHvVec1axissizeszCreator);
                        case 
'M'iCreatedEntity createBlock(0BM_CAMOUFLAGEvVec1axissizeszCreator);
                        case 
'N'iCreatedEntity createBlock(0BM_LOWGRAVITYvVec1axissizeszCreator);
                        case 
'P'iCreatedEntity createBlock(0BM_SLAPvVec1axissizeszCreator);
                        case 
'Q'iCreatedEntity createBlock(0BM_RANDOMvVec1axissizeszCreator);
                        case 
'R'iCreatedEntity createBlock(0BM_HONEYvVec1axissizeszCreator);
                        case 
'S'iCreatedEntity createBlock(0BM_BARRIER_CTvVec1axissizeszCreator);
                        case 
'T'iCreatedEntity createBlock(0BM_BARRIER_TvVec1axissizeszCreator);
                        case 
'U'iCreatedEntity createBlock(0BM_BOOTSOFSPEEDvVec1axissizeszCreator);
                        case 
'V'iCreatedEntity createBlock(0BM_GLASSvVec1axissizeszCreator);
                        case 
'Y'iCreatedEntity createBlock(0BM_MAGICCARPETvVec1axissizeszCreator);
                        case 
'Z'iCreatedEntity createBlock(0BM_LIGHTvVec1axissizeszCreator);
                        case 
'1'iCreatedEntity createBlock(0BM_MEGAHEALERvVec1axissizeszCreator);
                        case 
'2'iCreatedEntity createBlock(0BM_REDLIGHTvVec1axissizeszCreator);
                        case 
'3'iCreatedEntity createBlock(0BM_GREENLIGHTvVec1axissizeszCreator);
                        case 
'4'iCreatedEntity createBlock(0BM_BLUELIGHTvVec1axissizeszCreator);
                        case 
'5'iCreatedEntity createBlock(0BM_DOUBLEJUMPvVec1axissizeszCreator);
                        case 
'6'iCreatedEntity createBlock(0BM_ROCKETvVec1axissizeszCreator);
                        case 
'7'iCreatedEntity createBlock(0BM_NOCLIPvVec1axissizeszCreator);
                        case 
'8'iCreatedEntity createBlock(0BM_400GRAVITYvVec1axissizeszCreator);
                        case 
'9'iCreatedEntity createBlock(0BM_DELAYEDBHOPvVec1axissizeszCreator);
                        case 
'0'iCreatedEntity createBlock(0BM_BLINDTRAPvVec1axissizeszCreator);
                        case 
'W'iCreatedEntity createBlock(0BM_BLINDOPPOTEAMvVec1axissizeszCreator);
                        case 
'O'iCreatedEntity createBlock(0BM_SPAMDUCKvVec1axissizeszCreator);
                        case 
'L'iCreatedEntity createBlock(0BM_PULSEvVec1axissizeszCreator);
                        case 
'X'iCreatedEntity createBlock(0BM_ASPEEDBOOSTvVec1axissizeszCreator);
                        
                        case 
gTeleportSaveId:
                        {
                            
createTeleport(0TELEPORT_STARTvVec1szCreator);
                            
createTeleport(0TELEPORT_ENDvVec2szCreator);
                            
                            
//increment teleport count
                            
++teleCount;
                        }
                        
                        default:
                        {
                            
log_amx("%sInvalid block type: %c in: %s"gszPrefixszType[0], gszFile);
                            
                            
//decrement block counter because a block was not created
                            
--blockCount;
                        }
                    }
                    if (
pev_valid(iCreatedEntity)) {
                        
set_peviCreatedEntitypev_renderfxiRenderFX );
                        
set_peviCreatedEntitypev_rendermodeiRenderMode );
                        
set_peviCreatedEntitypev_rendercolorflRenderColor );
                        
set_peviCreatedEntitypev_renderamtflRenderAmt );
                    }
                }
            }
            
            
fclose(f);
            
            
//if a player is loading the blocks
            
if (id && id <= 32)
            {
                
//get players name
                
new szName[32];
                
get_user_name(idszName32);
                
                
//notify all admins that the player loaded blocks from file
                
for (new 1<= 32; ++i)
                {
                    
//make sure player is connected
                    
if (is_user_connected(i))
                    {
                        if (
get_user_flags(i) & BM_ADMIN_LEVEL)
                        {
                            
client_print(iprint_chat"%s'%s' loaded %d block%s and %d teleporter%s! Total entites in map: %d"gszPrefixszNameblockCount, (blockCount == "" "s"), teleCount, (teleCount == "" "s"),  entity_count());
                        }
                    }
                }
            }
        }
        else
        {
            
//if a player is loading the blocks
            
if (id && id <= 32)
            {
                
//notify player that the file could not be found
                
client_print(idprint_chat"%sCouldn't find file: %s"gszPrefixgszNewFile);
            }
        }
    }


+karma for help ^^


All times are GMT -4. The time now is 01:28.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.