AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   random_num ArrayGetString (https://forums.alliedmods.net/showthread.php?t=230258)

Gasa 11-22-2013 11:55

random_num ArrayGetString
 
Hey allied, can somone help me to get next model from array, this only make random, and also is it possible when i get next till end to start from first again thanx in advaance

PHP Code:

rand_mdl random_num(0ArraySize(g_sPropsModel) - 1)
ArrayGetString(g_sPropsModelrand_mdlszEntModelcharsmax(szEntModel)); 


akcaliberg 11-22-2013 12:45

Re: random_num ArrayGetString
 
0 is the first string of the array
(ArraySize(g_sPropsModel) - 1) value is the last string of the array.

rand_mdl + 1 will be the next string after the random string.

I didn't understand what you mean exactly.

ConnorMcLeod 11-22-2013 13:56

Re: random_num ArrayGetString
 
Here is the function you want :
PHP Code:

pickup_next_ent_model(model[], length)
{
    static 
lastString = -1;

    if( ++
lastString >= ArraySize(g_sPropsModel) )
    {
        
lastString 0;
    }

    
ArrayGetString(g_sPropsModellastStringmodellength);  


And here is how you gonna use it in your code :
PHP Code:

pickup_next_ent_model(szEntModelcharsmax(szEntModel)); 


Gasa 11-22-2013 14:50

Re: random_num ArrayGetString
 
thanks a lot working great just spaming this errors idk how to fix, and i saw somthing now this error only start spaming when i get to last model and then come first model again. here is logs

Thx Connor again this working great, and i solved error!

if( ++lastString > ArraySize(g_sPropsModel) )
to
if( ++lastString >= ArraySize(g_sPropsModel) )
PHP Code:

L 11/22/2013 20:48:53: [AMXXDisplaying debug trace (plugin "cs_prop_hunt.amxx")
L 11/22/2013 20:48:53: [AMXXRun time error 10native error (native "ArrayGetString")
L 11/22/2013 20:48:53: [AMXX]    [0cs_prop_hunt.sma::pickup_next_ent_model (line 513)
L 11/22/2013 20:48:53: [AMXX]    [1cs_prop_hunt.sma::fwd_CmdStart (line 536)
L 11/22/2013 20:48:55Invalid cellvector handle provided (1:5:5)
L 11/22/2013 20:48:55: [AMXXDisplaying debug trace (plugin "cs_prop_hunt.amxx")
L 11/22/2013 20:48:55: [AMXXRun time error 10native error (native "ArrayGetString")
L 11/22/2013 20:48:55: [AMXX]    [0cs_prop_hunt.sma::pickup_next_ent_model (line 513)
L 11/22/2013 20:48:55: [AMXX]    [1cs_prop_hunt.sma::fwd_CmdStart (line 536)
L 11/22/2013 20:48:56Invalid cellvector handle provided (1:5:5)
L 11/22/2013 20:48:56: [AMXXDisplaying debug trace (plugin "cs_prop_hunt.amxx")
L 11/22/2013 20:48:56: [AMXXRun time error 10native error (native "ArrayGetString")
L 11/22/2013 20:48:56: [AMXX]    [0cs_prop_hunt.sma::pickup_next_ent_model (line 513)
L 11/22/2013 20:48:56: [AMXX]    [1cs_prop_hunt.sma::fwd_CmdStart (line 536


ConnorMcLeod 11-22-2013 17:43

Re: random_num ArrayGetString
 
Sure, i've fixed it in previous post.

I'm affraid when i see you are using this code in CmdStart hook oO

Gasa 11-22-2013 18:29

Re: random_num ArrayGetString
 
Quote:

Originally Posted by ConnorMcLeod (Post 2064160)
Sure, i've fixed it in previous post.

I'm affraid when i see you are using this code in CmdStart hook oO

Exactly and THANKS A LOT


All times are GMT -4. The time now is 23:20.

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