Raised This Month: $32 Target: $400
 8% 

Not Saving and Model Isn't Sized


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnimalMonster
Senior Member
Join Date: May 2020
Old 10-31-2020 , 22:33   Not Saving and Model Isn't Sized
Reply With Quote #1

Hey everybody that reads this thread

There's a list of the problems i have:

1. My code does't save candies and the levels or just not loading them from nvault.

2. I tried to get a code for spawning objects from a killing rewards plugin for zpa and tried to change the size mins and maxs with the model's mins and maxs but didn t work in my tests , and in the past codes i wanted to make that entity be spawned somewhere on the map randomaly but didn't work.

if anybody has time for me i'm waiting, if anyone has any other advices for me in engine entity scripting just comment so i will make myself next time.

this code may be a mess, if it is don't hesitate to tell me so i can maybe optimize it.

Also idk why i put Save(id) in think

Code:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>
#include <engine>
#include <nvault>

#define PLUGIN "Candy System"
#define VERSION "1.0"
#define AUTHOR "DeclineD"

#define maxlevels 10
#define skills 2

new const item_class_name[] = "candy"

new g_model[] = "models/candy.mdl"

new Candies[33]

new 
Level[33][skills]

new 
SCosts[maxlevels+1] = {
    
3,
    
5,
    
7,
    
9,
    
11,
    
13,
    
15,
    
17,
    
19,
    
21
}

new 
GCosts[maxlevels+1] = {
    
3,
    
5,
    
7,
    
9,
    
11,
    
13,
    
15,
    
17,
    
19,
    
21
}

new 
Float:GFloats[maxlevels+1] = {
    
1.0,
    
0.950,
    
0.900,
    
0.850,
    
0.800,
    
0.750,
    
0.700,
    
0.650,
    
0.600,
    
0.550,
    
0.500
}

new 
Float:SFloats[maxlevels+1] = {
    
250.0,
    
300.0,
    
325.0,
    
350.0,
    
375.0,
    
400.0,
    
425.0,
    
450.0,
    
475.0,
    
500.0,
    
600.0
}

new 
g_vault

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_Touch"fwd_Touch")

    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
    
register_logevent("log_RStart"2"1=Round_Start")
    
    
register_forward(FM_PlayerPreThink"Think")
    
    
register_clcmd("say /skill""mSkills")
    
    
register_clcmd("lalala""lalala")
    
    
g_vault nvault_open("candysave")
}

public 
lalala(id)
{
    
Candies[id] = 99999
}

public 
plugin_end()
{
    
nvault_close(g_vault)
}

public 
plugin_precache()
{
    
precache_model(g_model)
}

public 
client_putinserver(id)
{
    
set_task(1.0"hud"id__"b")
    
    
Load(id)
}

public 
client_disconnected(id)
{
    
remove_task(id)
    
Save(id)
}

public 
Think(id)
{
    
Save(id)

    
set_pev(idpev_maxspeedSFloatsLevel[id][0] ])
    
set_pev(idpev_gravityGFloatsLevel[id][1] ])
    
set_pev(idpev_nextthink0.01)
}

public 
log_RStart()
{
    
deleteAllItems()
}

public 
fwd_Touch(touchertouched)
{
    if (!
is_user_alive(toucher) || !pev_valid(touched))
        return 
FMRES_IGNORED
    
new classname[32]
    
    
pev(touchedpev_classnameclassname31)
    
    
remove_entity(touched)
    
    
Candies[toucher] += 1
    
    set_dhudmessage
(24010160random_float(0.11.0), random_float(0.51.0), 02.03.01.01.0)
    
show_dhudmessage(toucher"[+1 Candy]")

    if (!
equal(classnameitem_class_name))
        return 
FMRES_IGNORED

    
return FMRES_IGNORED
}

public 
fw_PlayerKilled(victimattackershouldgib)
{
    new 
origin[3]
    
get_user_origin(victim origin)

    
addItem(origin)
}

public 
addItem(origin[3])
{
    new 
ent fm_create_entity("info_target")

    
set_pev(entpev_classnameitem_class_name)
    
    
engfunc(EngFunc_SetModel,entg_model)

    
set_pev(ent,pev_mins,Float:{-19.40,1.17,-33.11})
    
set_pev(ent,pev_maxs,Float:{21.99,87.77,39.06})
    
set_pev(ent,pev_size,Float:{-19.40,1.17,-33.11,21.99,87.77,39.06})
    
engfunc(EngFunc_SetSize,ent,Float:{-19.40,1.17,-33.11},Float:{21.99,87.77,39.06})

    
set_pev(ent,pev_solid,SOLID_BBOX)
    
set_pev(ent,pev_movetype,MOVETYPE_TOSS)
    
    new 
Float:fOrigin[3]
    
IVecFVec(originfOrigin)
    
set_pev(entpev_originfOrigin)
    
    
set_pev(ent,pev_renderfx,kRenderFxGlowShell)

    new 
Float:velocity[3];
    
pev(ent,pev_velocity,velocity);
    
velocity[2] = random_float(265.0,285.0);
    
set_pev(ent,pev_velocity,velocity)

    switch(
random_num(1,4))
    {
        case 
1set_pev(ent,pev_rendercolor,Float:{0.0,0.0,255.0})
        case 
2set_pev(ent,pev_rendercolor,Float:{0.0,255.0,0.0})
        case 
3set_pev(ent,pev_rendercolor,Float:{255.0,0.0,0.0})
        case 
4set_pev(ent,pev_rendercolor,Float:{255.0,255.0,255.0})
    }
}

public 
deleteAllItems()
{
    new 
ent FM_NULLENT
    
static string_class[] = "classname"
    
while ((ent engfunc(EngFunc_FindEntityByStringentstring_classitem_class_name))) 
    
set_pev(entpev_flagsFL_KILLME)
}

public 
mSkills(id)
{
    new 
menu menu_create("\ySkills \rMenu \r[\yLIMITED\r]""mHand")
    new 
text[128]
    
    if(
Level[id][0] == maxlevels)
    {
        
formatex(textcharsmax(text), "Speed \yLv. \r%d")
    }
    else if(
Level[id][0] < maxlevelsformatex(textcharsmax(text), "Speed \yLv. %d \r(%d Candy)"Level[id][0], SCostsLevel[id][0] ])
    
    
menu_additem(menutext)
    
    if(
Level[id][1] == maxlevels)
    {
        
formatex(textcharsmax(text), "Gravity \yLv. \r%d")
    }
    else if(
Level[id][1] < maxlevelsformatex(textcharsmax(text), "Gravity \yLv. %d \r(%d Candy)",Level[id][1], GCostsLevel[id][1] ])
    
    
menu_additem(menutext)
    
    
menu_setprop(menuMPROP_EXITNAME"Exit")
    
    
menu_display(idmenu)
}

public 
mHand(idmenuitem)
{
    switch(
item)
    {
        case 
0: {
            if(
Candies[id] < SCostsLevel[id][0] ]) return;            
            if(
Level[id][0] > charsmax(SCosts)) return;
            if(
Level[id][0] == maxlevels) return;

            
Candies[id] = Candies[id] - SCostsLevel[id][0] ]
            
Level[id][0] += 1
            
            menu_display
(idmenu)

            
client_print_color(idid"You just brought speed ^4level %d"Level[id][0])
        }
        
        case 
1: {
            if(
Candies[id] < GCostsLevel[id][1] ]) return;
            if(
Level[id][1] > charsmax(GCosts)) return;
            if(
Level[id][1] == maxlevels) return;

            
Candies[id] = Candies[id] - GCostsLevel[id][1] ]
            
Level[id][1] += 1
            
            menu_display
(idmenu)

            
client_print_color(idid"You just brought gravity ^4level %d"Level[id][1])

        }
    }
}

public 
hud(id)
{    
    
set_dhudmessage(120102550.00.300.10.10.50.5)
    
    if(
Level[id][0] + Level[id][1] == 20)
    
show_dhudmessage(id"[(-Candy-)] - %d^n^n[(-Level-)] - MAXED"Candies[id])
    else 
show_dhudmessage(id"[(-Candy-)] - %d^n^n[(-Level-)] - %d"Candies[id], Level[id][0] + Level[id][1])
}

public 
Save(id)
{
    new 
text[128], szIP[10]

    
get_user_ip(idszIPcharsmax(szIP), 1)

    
formatex(textcharsmax(text), "%i#%i#%i#"Candies[id], Level[id][0], Level[id][1])
    
    
nvault_set(g_vaultszIPtext)
}

public 
Load(id)
{
    new 
text[128], szIP[10]
    
    
get_user_ip(idszIPcharsmax(szIP), 1)
    
    
formatex(textcharsmax(text), "%i#%i#%i#"Candies[id], Level[id][0], Level[id][1])
    
    
nvault_get(g_vaultszIPtext)
    
    
replace_all(textcharsmax(text), "#"" ")
    
    new 
szCandies[10], szLevelS[10], szLevelG[10]
    
    
parse(textszCandiescharsmax(szCandies), szLevelScharsmax(szLevelS), szLevelGcharsmax(szLevelG))
    
    
Candies[id] = str_to_num(szCandies)
    
Level[id][0] = str_to_num(szLevelS)
    
Level[id][1] = str_to_num(szLevelG)



Last edited by AnimalMonster; 10-31-2020 at 23:43.
AnimalMonster is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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