AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   DispatchKeyValue woes (https://forums.alliedmods.net/showthread.php?t=3094)

Bad HAL 9000 06-25-2004 21:20

DispatchKeyValue woes
 
Im pretty new at this entity stuff, I have managed to get some stuff working, but am having trouble here

Code:

@PointClass base(Target) size(-16 -16 -36, 16 16 36) color(255 125 0) = ts_powerup : "TS powerup"
[
        pwuptype(choices) : "Powerup Type" : 0 =
        [
                0: "Random"
                1: "Slow Motion"
                2: "Infinite Clip"
                4: "Kung Fu"
                8: "Slow Pause"
                16: "Double Firerate"
                32: "Grenade"
                64: "Health"
                128: "Armor"
                256: "Low Gravity"
        ]

        pwupduration(integer) : "Respawn time" : 60

        message(string) : "Message when pick up"
]

From the FDG of the ent I want to make

Now, here is my code to spawn the ent I want, most of it was from AssKickR

Code:
public create_powerup(id) {  /*Made by AssKicR.. CopyLeft 2004->Eternity*/   client_print(id,print_chat,"You have tried to spawn a powerup") new ent = create_entity("ts_powerup")   DispatchKeyValue(ent, "pwuptype", "256") // DispatchKeyValue(ent, "pwuptype", 256)  // invalid argument type, cant use int... wtf DispatchSpawn(ent)   new Float:fNewOrigin[3]   entity_get_vector(id, EV_VEC_origin, fNewOrigin)   entity_set_origin(ent, fNewOrigin) fake_touch(id,ent) fake_touch(ent,id) remove_entity(ent)     return PLUGIN_HANDLED    }

Ryan 06-26-2004 03:08

EDIT: I missed the part about the FGD file, my bad.

AssKicR 06-26-2004 03:19

wrong Ryan

This ent is not an "info_target" it is a "ts_powerup"

DELETE UR POST... IT IS TOTALLY OFFTOPIC AND WRONG!!!!

Bad HAL 9000 06-26-2004 05:52

hmm, yea I dont need the model, I need the functionality the ent provides... and AssKicr that seemed inaproprate, he was only trying to help

SidLuke 06-26-2004 11:41

Create and Give Item will be in TS Module :P
Item needs some time to spawn so you can't remove it. Set task (1 sec ? )with ent as a parametr and then touch and remove it.

AssKicR 06-26-2004 12:41

sooo.. like this

PS: Bad Hal 9000: i was just telling him that what he said was wrong.. What is inaproprate about that?

Code:
public create_powerup(id) {     /*Made by AssKicR.. CopyLeft 2004->Eternity*/     new ent = create_entity("ts_powerup")     DispatchKeyValue(ent, "pwuptype", "256")     DispatchSpawn(ent)     new parm[2]     parm[0]=id     parm[1]=ent     set_task(1.0,"give_powerup",0,"parm",2) } public give_powerup(parm[]) {     /*Made by AssKicR.. CopyLeft 2004->Eternity*/     new id = parm[0]     new ent = parm[1]     new Float:fNewOrigin[3]     entity_get_vector(id, EV_VEC_origin, fNewOrigin)     entity_set_origin(ent, fNewOrigin)     fake_touch(id,ent)     fake_touch(ent,id)     remove_entity(ent) }

SidLuke 06-26-2004 12:51

Code:

static cell AMX_NATIVE_CALL create_pwup(AMX *amx, cell *params){ // pwup ,origin[3]

        string_t item = MAKE_STRING("ts_powerup");
        edict_t        *pent = CREATE_NAMED_ENTITY( item );
        if ( FNullEnt( pent ) ){
                return 0;
        }

        KeyValueData pkvd;
        char szTemp[16];

        sprintf(szTemp,"%d",params[1]);

        pkvd.szClassName = (char *)STRING(pent->v.classname);
        pkvd.szKeyName = "pwuptype"; // type
        pkvd.szValue = szTemp;
        pkvd.fHandled = false;
        MDLL_KeyValue(pent, &pkvd);

        pkvd.szClassName = (char *)STRING(pent->v.classname);
        pkvd.szKeyName = "pwupduration"; // duration
        pkvd.szValue = "60";
        pkvd.fHandled = false;
        MDLL_KeyValue(pent, &pkvd);

/*
        pkvd.szClassName = (char *)STRING(pent->v.classname);
        pkvd.szKeyName = "message";
        pkvd.szValue = "";
        pMDLL_KeyValue(pEntity, &pkvd);
*/
        cell *vInput = MF_GetAmxAddr(amx,params[2]);

        float fNewX = *(float *)((void *)&vInput[0]);
        float fNewY = *(float *)((void *)&vInput[1]);
        float fNewZ = *(float *)((void *)&vInput[2]);

        vec3_t vNewValue = vec3_t(fNewX, fNewY, fNewZ);

        MDLL_Spawn(pent);
        pent->v.origin = vNewValue;

        return ENTINDEX(pent);
}

// create_pwup -> !wait! -> give_pwup
static cell AMX_NATIVE_CALL give_pwup(AMX *amx, cell *params){ // index,pwupentindex

        edict_t* pent = INDEXENT(params[2]);
        if ( FNullEnt( pent ) || strcmp("ts_powerup",STRING(pent->v.classname))!=0 ){
                return 0;
        }
       
        int id = params[1];
        if ( id<1 || id>gpGlobals->maxClients ){
                MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
                return 0;
        }
        CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
        if ( !pPlayer->ingame || !pPlayer->IsAlive() ){
                REMOVE_ENTITY(pent);
                return 0;
        }

        pent->v.origin = pPlayer->pEdict->v.origin;

        MDLL_Touch(pent, pPlayer->pEdict);

        REMOVE_ENTITY(pent);

        return 1;

}

:P

Bad HAL 9000 06-26-2004 13:03

AssKicR the RED AND BOLD AND BIG TEXT! :P

Also, that code didnt spawn the ent, :(

Bad HAL 9000 06-28-2004 23:07

Bumpage, this doesnt work


Code:
public create_powerup(id) {     /*Made by AssKicR.. CopyLeft 2004->Eternity*/     new ent = create_entity("ts_powerup")     new pwup[4]     format(pwup,4,"%d",256)     DispatchKeyValue(ent, "pwuptype", pwup)     DispatchKeyValue(ent, "duration", "60")     DispatchKeyValue(ent, "message", "")     DispatchSpawn(ent)     new parm[2]     parm[0]=id     parm[1]=ent     set_task(1.0,"give_powerup",0,"parm",2) } public give_powerup(parm[]) {     /*Made by AssKicR.. CopyLeft 2004->Eternity*/     new id = parm[0]     new ent = parm[1]     new Float:fNewOrigin[3]     entity_get_vector(id, EV_VEC_origin, fNewOrigin)     entity_set_origin(ent, fNewOrigin)     fake_touch(id,ent)     fake_touch(ent,id)     remove_entity(ent) }

[FBX] 06-29-2004 01:47

key value pairs must be legit for the object you are creating, you cant just make up your own (what mod is this for???) You also must set the location of an entity before dispatchingspawn. If you are not sure what the valid key value pairs are for an entity, load a map in notepad or something (it'll take a while to load) and then search for the entity name. You should realize how entities are described in the map after you look at it for a bit and every entity's key value pair that is required will be listed. I notice that message is "" and its possible you dont even need the key value pair. Before messing with key value pairs however, try to recreate the entity that is on the map exactly at it is first.


All times are GMT -4. The time now is 14:40.

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