w tym temacie do którego podałem linka wyżej, ktoś podał wersje na której zapisuje sie worki na stale na mapach ale nie potrafię edytować tak, żeby odnawiały sie po każdej rundzie, tzn np jeżeli rozwali sie je w 1 rundzie to już nie pojawia sie do końca mapy tylko po ponownym jej włączeniu. na kilkunastu serwerach, miedzy innymi serwerze zm steru widziałem ze worki pojawiają sie po nowej rundzie. Prosił bym o przerobienie tego pluginu. Zamieszczam kod:
/* AMXX PLUGIN Pallets with Bags Version : 0.3c Author : SAMURAI Have a nice day now */ #include <amxmodx> #include <amxmisc> #include <fakemeta> #include <xs> #define PLUGIN_NAME "Pallets with Bags" #define PLUGIN_VERSION "0.3c" #define PLUGIN_AUTHOR "SAMURAI" // The sizes of models #define PALLET_MINS Float:{ -27.260000, -22.280001, -22.290001 } #define PALLET_MAXS Float:{ 27.340000, 26.629999, 29.020000 } // from fakemeta util by VEN #define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2) #define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1) // this is mine #define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor,%1) // cvars new pnumplugin, remove_nrnd, maxpallets, phealth; // num of pallets with bags new palletscout = 0; /* Models for pallets with bags . Are available 2 models, will be set a random of them */ new g_models[][] = { "models/pallet_with_bags.mdl", "models/pallet_with_bags2.mdl" } new g_class[] = "amxx_pallets"; /************************************************************* ************************* AMXX PLUGIN ************************* **************************************************************/ public plugin_init() { /* Register the plugin */ register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR) /* Register the cvars */ pnumplugin = register_cvar("pallets_wbags","1"); // 1 = ON; 0 = OFF remove_nrnd = register_cvar("pallets_wbags_nroundrem","0"); maxpallets = register_cvar("pallets_wbags_max","64"); // max number of pallets with bags phealth = register_cvar("pallets_wbags_health","0"); // set the health to a pallet with bags /* Game Events */ register_event("HLTV","event_newround", "a","1=0", "2=0"); // it's called every on new round /* This is for menuz: */ register_menucmd(register_menuid("yPallets with Bags:"), 1023, "menu_command" ); register_clcmd("say pallets_menu","show_the_menu",ADMIN_RCON,"Open the Pallets with Bags menu"); } public plugin_precache() { for(new i;i < sizeof g_models;i++) engfunc(EngFunc_PrecacheModel,g_models[i]); } public show_the_menu(id,level,cid) { // check if user doesen't have admin if( ! cmd_access( id,level, cid , 0 )) return PLUGIN_HANDLED; // check if the plugin cvar is turned off if( ! get_pcvar_num( pnumplugin ) ) return PLUGIN_HANDLED; // check if user isn't alive if( ! is_user_alive( id ) ) { client_print( id, print_chat, "[AMXX] You can't place a pallet with bags because you are dead" ); return PLUGIN_HANDLED; } new szMenuBody[256]; new keys; new nLen = format( szMenuBody, 255, "yPallets with Bags:^n" ); nLen += format( szMenuBody[nLen], 255-nLen, "^nw1. Place a pallet with bags" ); nLen += format( szMenuBody[nLen], 255-nLen, "^nw2. Remove a pallet with bags" ); nLen += format( szMenuBody[nLen], 255-nLen, "^nw3. Remove all pallets with bags" ); nLen += format( szMenuBody[nLen], 255-nLen, "^nw4. Save Pallets with Bags origins" ); nLen += format( szMenuBody[nLen], 255-nLen, "^n^nw0. Exit" ); keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<9) show_menu( id, keys, szMenuBody, -1 ); // depends what you want, if is continue will appear on chat what the admin sayd return PLUGIN_HANDLED; } public plugin_cfg() { static sConfigsDir[256], sFile[256], PalletDir[256]; get_configsdir(sConfigsDir, sizeof sConfigsDir - 1); static sMapName[32]; get_mapname(sMapName, sizeof sMapName - 1); formatex(PalletDir, sizeof PalletDir - 1,"%s/Pallets with Bags",sConfigsDir); formatex(sFile, sizeof sFile - 1, "%s/%s_pallets_with_bags.cfg",PalletDir,sMapName); //formatex(sFile, sizeof sFile - 1, "%s/%s_pallets_with_bags.cfg", sConfigsDir, sMapName); if(!dir_exists(PalletDir)) { mkdir(PalletDir); } if(!file_exists(sFile)) { write_file(sFile,""); } static sFileOrigin[3][32], sFileAngles[3][32], iLine, iLength, sBuffer[256]; static sTemp1[128], sTemp2[128]; static Float:fOrigin[3], Float:fAngles[3]; while(read_file(sFile, iLine++, sBuffer, sizeof sBuffer - 1, iLength)) { if((sBuffer[0]==';') || !iLength) continue; strtok(sBuffer, sTemp1, sizeof sTemp1 - 1, sTemp2, sizeof sTemp2 - 1, '|', 0); parse(sTemp1, sFileOrigin[0], sizeof sFileOrigin[] - 1, sFileOrigin[1], sizeof sFileOrigin[] - 1, sFileOrigin[2], sizeof sFileOrigin[] - 1); fOrigin[0] = str_to_float(sFileOrigin[0]); fOrigin[1] = str_to_float(sFileOrigin[1]); fOrigin[2] = str_to_float(sFileOrigin[2]); parse(sTemp2, sFileAngles[0], sizeof sFileAngles[] - 1, sFileAngles[1], sizeof sFileAngles[] - 1, sFileAngles[2], sizeof sFileAngles[] - 1); fAngles[0] = str_to_float(sFileAngles[0]); fAngles[1] = str_to_float(sFileAngles[1]); fAngles[2] = str_to_float(sFileAngles[2]); ///////////////////////////////////////////////////////////////////// if( palletscout == get_pcvar_num(maxpallets) ) { server_print("Can't be placed more than %d pallets with bags",get_pcvar_num(maxpallets)); return 0; } new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall")); engfunc(EngFunc_SetOrigin, ent, fOrigin); if(!ent) return 0; engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]); set_pev(ent,pev_classname,g_class); dllfunc(DLLFunc_Spawn, ent); set_pev(ent,pev_solid,SOLID_BBOX); // set the movetype set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff // set sizes static Float:p_mins[3], Float:p_maxs[3]; p_mins = PALLET_MINS; p_maxs = PALLET_MAXS; engfunc(EngFunc_SetSize, ent, p_mins, p_maxs); set_pev(ent, pev_mins, p_mins); set_pev(ent, pev_maxs, p_maxs ); set_pev(ent, pev_absmin, p_mins); set_pev(ent, pev_absmax, p_maxs ); // now the damage stuff, to set to take it or no // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags // else, if you want to make it destroyable, just set the health > 0 and will be // destroyable. new Float:p_cvar_health = get_pcvar_float(phealth); switch(p_cvar_health) { case 0.0 : { set_pev(ent,pev_takedamage,DAMAGE_NO); } default : { set_pev(ent,pev_health,p_cvar_health); set_pev(ent,pev_takedamage,DAMAGE_YES); } } set_pev(ent,pev_angles,fAngles); // drop entity to floor fm_drop_to_floor(ent); // num .. palletscout++; } return 1; } public menu_command(id,key,level,cid) { switch( key ) { // place a pallet with bags case 0: { place_palletwbags(id); show_the_menu(id,level,cid); } // remove a pallet with bags case 1: { new ent, body, class[32]; get_user_aiming(id, ent, body); if (pev_valid(ent)) { pev(ent, pev_classname, class, 31); if (equal(class, g_class)) { fm_remove_entity(ent); palletscout--; } else client_print(id, print_chat, "[AMXX] You are not aiming at a pallet with bags"); } else client_print(id, print_chat, "[AMXX] You are not aiming at a valid entity !"); show_the_menu(id,level,cid); } // remove all pallets with bags case 2: { remove_allpalletswbags(); client_print(id,print_chat,"[AMXX] You removed all pallets with bags !"); show_the_menu(id,level,cid); } // save origins case 3: { static sConfigsDir[256], sFile[256], PalletDir[256]; get_configsdir(sConfigsDir, sizeof sConfigsDir - 1); static sMapName[32]; get_mapname(sMapName, sizeof sMapName - 1); formatex(PalletDir, sizeof PalletDir - 1,"%s/Pallets with Bags",sConfigsDir); formatex(sFile, sizeof sFile - 1, "%s/%s_pallets_with_bags.cfg",PalletDir,sMapName); if(file_exists(sFile)) delete_file(sFile); new iEnt = -1, Float:fEntOrigin[3], Float:fEntAngles[3], iCount; static sBuffer[256]; while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", g_class))) { pev(iEnt, pev_origin, fEntOrigin); pev(iEnt, pev_angles, fEntAngles); formatex(sBuffer, sizeof sBuffer - 1, "%f %f %f | %f %f %f", fEntOrigin[0], fEntOrigin[1], fEntOrigin[2], fEntAngles[0], fEntAngles[1], fEntAngles[2]); write_file(sFile, sBuffer, -1); iCount++; } client_print(id, print_chat, "[AMXX] Successfuly saved all pallets with bags origins (%d) for map %s!", iCount,sMapName); show_the_menu(id,level,cid); } } return PLUGIN_HANDLED; } public place_palletwbags(id) { if( palletscout == get_pcvar_num(maxpallets) ) { client_print(id,print_chat,"You can't place more than %d pallets with bags",get_pcvar_num(maxpallets)); return PLUGIN_HANDLED; } // create a new entity new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall")); // set a name to the entity set_pev(ent,pev_classname,g_class); // set model engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]); // register a new var. for origin static Float:xorigin[3]; get_user_hitpoint(id,xorigin); // check if user is aiming at the air if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY) { client_print(id,print_chat,"[AMXX] You can't place a pallet with bags on the air"); return PLUGIN_HANDLED; } // set sizes static Float:p_mins[3], Float:p_maxs[3]; p_mins = PALLET_MINS; p_maxs = PALLET_MAXS; engfunc(EngFunc_SetSize, ent, p_mins, p_maxs); set_pev(ent, pev_mins, p_mins); set_pev(ent, pev_maxs, p_maxs ); set_pev(ent, pev_absmin, p_mins); set_pev(ent, pev_absmax, p_maxs ); // set the rock of origin where is user placed engfunc(EngFunc_SetOrigin, ent, xorigin); // make the rock solid set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block // set the movetype set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff // now the damage stuff, to set to take it or no // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags // else, if you want to make it destroyable, just set the health > 0 and will be // destroyable. new Float:p_cvar_health = get_pcvar_float(phealth); switch(p_cvar_health) { case 0.0 : { set_pev(ent,pev_takedamage,DAMAGE_NO); } default : { set_pev(ent,pev_health,p_cvar_health); set_pev(ent,pev_takedamage,DAMAGE_YES); } } static Float:rvec[3]; pev(id,pev_v_angle,rvec); rvec[0] = 0.0; set_pev(ent,pev_angles,rvec); // drop entity to floor fm_drop_to_floor(ent); // num .. palletscout++; // confirm message client_print(id,print_chat,"[AMXX] You placed a Pallet with Bags !"); return PLUGIN_HANDLED; } /* ==================================================== get_user_hitpoin stock . Was maked by P34nut, and is like get_user_aiming but is with floats and better <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/ohmy.gif' class='bbc_emoticon' alt=':o' /> ====================================================*/ stock get_user_hitpoint(id, Float:hOrigin[3]) { if ( ! is_user_alive( id )) return 0; new Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3]; new 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, 9999.9, feOrigin); xs_vec_add(fvOrigin, feOrigin, feOrigin); engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id); global_get(glb_trace_endpos, hOrigin); return 1; } /* ==================================================== This is called on every round, at start up, with HLTV logevent. So if the "pallets_wbags_nroundrem" cvar is set to 1, all placed pallets with bags will be removed. ====================================================*/ public event_newround() { if( get_pcvar_num ( remove_nrnd ) == 1) remove_allpalletswbags(); } /* ==================================================== This is a stock to help for remove all pallets with bags placed . Is called on new round if the cvar "pallets_wbags_nroundrem" is set 1. ====================================================*/ stock remove_allpalletswbags() { new pallets = -1; while((pallets = fm_find_ent_by_class(pallets, g_class))) fm_remove_entity(pallets); palletscout = 0; }