Raised This Month: $12 Target: $400
 3% 

push array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
killergirl
Senior Member
Join Date: Jul 2010
Old 03-13-2012 , 15:10   push array
Reply With Quote #1

I know it's wrong, but the code below will explain my problem.

PHP Code:
arr[0] = "some string #1"
arr[1] = "some string #2"
...
arr[9] = empty

if(
statement)
   
swap(arr[0], arr[1])
// but how? 
I made my search, but I don't know how to use it...
ArraySort() http://www.amxmodx.org/funcwiki.php?go=func&id=1208
ArraySwap() http://www.amxmodx.org/funcwiki.php?go=func&id=1204
ArrayPushString() http://www.amxmodx.org/funcwiki.php?go=func&id=1197

Can anyone give me an example?

Last edited by killergirl; 03-13-2012 at 15:11.
killergirl is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-13-2012 , 16:01   Re: push array
Reply With Quote #2

Are you actually trying to sort all elements in the array or just switch two elements?
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
killergirl
Senior Member
Join Date: Jul 2010
Old 03-13-2012 , 16:27   Re: push array
Reply With Quote #3

######

Last edited by killergirl; 03-23-2012 at 06:07.
killergirl is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 03-13-2012 , 16:33   Re: push array
Reply With Quote #4

PHP Code:
// Switch element 0 with element 1
new temp[sizeof arr[]];
temp arr[0];
arr[0] = arr[1];
arr[1] = temp
EDIT: Meh, not really relevant.

You could use static arrays and SortCustom2D() for this.

Last edited by hleV; 03-13-2012 at 16:35.
hleV is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-13-2012 , 23:34   Re: push array
Reply With Quote #5

Code:
    for(i = 0; i < 10; i++){
        ArrayGetArray(entries, i, data)
        
        server_print("#%d", i+1, data[key_data], data[key_values])
    }
->
Code:
    for(i = 0; i < 10; i++){
        ArrayGetArray(entries, i, data)
        
        server_print("#%d %s %d", i+1, data[key_data], data[key_values])
    }
It should be sorting it fine.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
killergirl
Senior Member
Join Date: Jul 2010
Old 03-14-2012 , 03:00   Re: push array
Reply With Quote #6

Quote:
Originally Posted by Emp` View Post
Code:
server_print("#%d %s %d", i+1, data[key_data], data[key_values])
It should be sorting it fine.
L O L !

Oh God Why ?!

I should go to a doctor, I'm blind ! I thought it was caused by ArraySort(), but NOT ! It's a simple basic code. Damn

Anyway, thanks Emp`!
killergirl is offline
Reply



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 21:04.


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