AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set_task problem (https://forums.alliedmods.net/showthread.php?t=21819)

MaximusBrood 12-11-2005 06:04

Set_task problem
 
I've been trying to get this fixed, if anybody can help me http://www.amxmodx.org/forums/images...on_biggrin.gif

Code:
public cmdSpawn(id) {     new Float:curOrigin[3]     entity_get_vector(id, EV_VEC_origin, curOrigin)         new data[1]     data[0] = curOrigin         client_print(id, print_chat, "[AMXX] You got 5 seconds to move")     set_task(5.0, "createEnt", 0, data, 1)         return PLUGIN_HANDLED } public createEnt(data[]) {     new Float:origin[3]     origin = data[0]         //some entity creation code, doesnt matter right now     //Just declare the origin to make a good example ^^     entity_set_origin(ent, origin)         //Done :)     return PLUGIN_HANDLED }

VEN 12-11-2005 06:33

Re: Set_task problem
 
I know here are is a tag mismatch but it would work.
Code:
public cmdSpawn(id) {     new Float:curOrigin[3]     entity_get_vector(id, EV_VEC_origin, curOrigin)         client_print(id, print_chat, "[AMXX] You got 5 seconds to move")     set_task(5.0, "createEnt", 0, curOrigin, 3)         return PLUGIN_HANDLED } public createEnt(Float:origin[3]) {     //some entity creation code, doesnt matter right now     //Just declare the origin to make a good example ^^     entity_set_origin(ent, origin)         //Done :)     return PLUGIN_HANDLED }

MaximusBrood 12-11-2005 07:26

Thnx for the solution :D

But, is there any way to get around the warning?

VEN 12-11-2005 07:54

Use global float and store origin to it and then get it back.

MaximusBrood 12-11-2005 07:58

Quote:

Originally Posted by VEN
Use global float and store origin to it and then get it back.

Thats what I was thinking of before I asked it here.

But I don't like 'global var function hacking', it not neat, and it can easy create bugs.

---

But thnx for the answer :D

Basic-Master 12-11-2005 08:33

Code:
public cmdSpawn(id) {     new Float:curOrigin[3]     entity_get_vector(id, EV_VEC_origin, curOrigin)         new data[3]     FVecIVec(curOrigin, data)         client_print(id, print_chat, "[AMXX] You got 5 seconds to move")     set_task(5.0, "createEnt", 0, data, 3)         return PLUGIN_HANDLED } public createEnt(data[]) {     new Float:origin[3]     origin[0] = float(data[0])     origin[1] = float(data[1])     origin[2] = float(data[2])         //some entity creation code, doesnt matter right now     //Just declare the origin to make a good example ^"     entity_set_origin(ent, origin)         //Done :)     return PLUGIN_HANDLED }

that should work.

Twilight Suzuka 12-11-2005 11:08

There is a IVecFVec function too you know.

Code:

public cmdSpawn(id)
{
    new Float:curOrigin[3]
    entity_get_vector(id, EV_VEC_origin, curOrigin)
   
    new data[3]
    FVecIVec(curOrigin, data)
   
    client_print(id, print_chat, "[AMXX] You got 5 seconds to move")
    set_task(5.0, "createEnt", 0, data, 3)
   
    return PLUGIN_HANDLED
}

public createEnt(data[])
{
    new Float:origin[3]
    IVecFVec(data, origin)

    //some entity creation code, doesnt matter right now
    //Just declare the origin to make a good example ^"
    entity_set_origin(ent, origin)
   
    //Done Smile
    return PLUGIN_HANDLED
}


Basic-Master 12-12-2005 08:35

I know, but the array size doesn't match. it would return something like:

Error: Array sizes do not match, or destination array is too small on line gaben

Jordan 12-12-2005 16:54

Change got to have please thanks :D

XxAvalanchexX 12-12-2005 21:40

Quote:

Originally Posted by Basic-Master
I know, but the array size doesn't match. it would return something like:

Error: Array sizes do not match, or destination array is too small on line gaben

The only problem is that one doesn't have a size specifically stated. Just change this:

Code:
public createEnt(data[])

to this:

Code:
public createEnt(data[3])


All times are GMT -4. The time now is 16:08.

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