SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/12/2016, 03:31 PM   #11
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,974
Reputation: 426
Default Re: Array

Quote:
Originally Posted by SickAttack View Post
Without a plugin, in pawn itself.
and that's because....

OP never said with or without plugin he just asked its possible or not. We all know its not possible in pawn itself -_-
__________________

SyS is offline   Reply With Quote
Old 19/12/2016, 03:38 PM   #12
SickAttack
Godfather
 
Join Date: Dec 2013
Posts: 5,157
Reputation: 751
Default Re: Array

Quote:
Originally Posted by Sreyas View Post
and that's because....

OP never said with or without plugin he just asked its possible or not. We all know its not possible in pawn itself -_-
It's only logical that he's talking about PAWN, plugins are in a different language. But you may be right in global terms.

Just leave it where it stands, I'm not going to reply anymore either way xD

Quote:
Originally Posted by SickAttack View Post
It is possible if you put each number in their index however.

if(array[number] == number]) or even as a boolean.
SickAttack is offline   Reply With Quote
Old 19/12/2016, 03:39 PM   #13
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,974
Reputation: 426
Default Re: Array

Quote:
Originally Posted by SickAttack View Post
Just leave it where it stands, I'm not going to reply anymore either way xD
No no don't take it in bad way i'm not arguing i was pointing to OP's question only
__________________

SyS is offline   Reply With Quote
Old 18/03/2017, 03:15 PM   #14
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,974
Reputation: 426
Default Re: Array

Sorry for late reply but i found something. Its actually possible. Since pawn is type less we can make use string function strfind to check it . I made a small macro for convenience. Its actually faster than normal looping.But there is a disadvantage if we have an element value equal to 0 the checking stops on that index and further index would not be checked and will return -1.I will try to find a method to overcome this.

PHP Code:
#define arrfind(%0,%1) strfind(%0,{%1},false,0)

main()
{
    new array[]={
6,2,3,3,2340,78};

    
printf"index = %d" arrfind(array,3));//will print 2
    

now there is another way for checking without looping which is recursion but i think normal looping is better than that.
__________________

SyS is offline   Reply With Quote
Old 18/03/2017, 03:22 PM   #15
GhostHacker9
Big Clucker
 
GhostHacker9's Avatar
 
Join Date: Jan 2017
Location: Kernel
Posts: 77
Reputation: 85
Default Re: Array

Quote:
Originally Posted by Sreyas View Post
Sorry for late reply but i found something. Its actually possible. Since pawn is type less we can make use string function strfind to check it . I made a small macro for convenience. Its actually faster than normal looping.But there is a disadvantage if we have an element value equal to 0 the checking stops on that index and further index would not be checked and will return -1.I will try to find a method to overcome this.

PHP Code:
#define arrfind(%0,%1) strfind(%0,{%1},false,0)

main()
{
    new array[]={
6,2,3,3,2340,78};

    
printf"index = %d" arrfind(array,3));//will print 2
    

now there is another way for checking without looping which is recursion but i think normal looping is better than that.
That's fucking useful and gave me some ideas. Have a rep.
GhostHacker9 is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[3D Array] Defining an array entry with another array introzen Scripting Help 3 04/04/2016 08:29 PM
(dFile) error 047: array sizes do not match, or destination array is too small Jack_Leslie Scripting Help 0 06/09/2011 02:20 AM
(dFile) error 047: array sizes do not match, or destination array is too small Jack_Leslie Scripting Help 8 01/09/2011 06:32 AM
[SOLVED]error 047: array sizes do not match, or destination array is too small help! Help Archive 7 18/06/2011 09:09 PM
[Sloved]error 047: array sizes do not match, or destination array is too small CoaPsyFactor Help Archive 1 09/06/2011 09:27 PM


All times are GMT. The time now is 06:18 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.