Raised This Month: $32 Target: $400
 8% 

About string question


Post New Thread Reply   
 
Thread Tools Display Modes
yl2401
Member
Join Date: Nov 2011
Old 08-07-2015 , 12:10   Re: About string question
Reply With Quote #21

Quote:
Originally Posted by grs4 View Post
look: g_data[id][X1][X2]
But tell us, what do you want to be in X1, and X2 ?

edit, im checking, wait for an edit/answer
read data.ini
HTML Code:
"Player" "102021211000100020000000000000000" "221211200122110000000000000000000" "110000000000000000000000000000000" "000000000000000000000000000000000" "000000000000000000000000000000000" "000000000000000000000000000000000"
g_data[id][0] = 102021211000100020...
g_data[id][0][0] = 1
g_data[id][0][1] = 0
g_data[id][0][2] = 2

g_data[id][1] = 221211200122110...
g_data[id][1][0] = 2
g_data[id][1][1] = 2
g_data[id][1][2] = 1

X1 = "221211200122110000000000000000000"
X2 only 0/1/2.

Last edited by yl2401; 08-07-2015 at 12:11.
yl2401 is offline
yl2401
Member
Join Date: Nov 2011
Old 08-07-2015 , 12:16   Re: About string question
Reply With Quote #22

Quote:
Originally Posted by grs4 View Post
look: g_data[id][X1][X2]
But tell us, what do you want to be in X1, and X2 ?

edit, im checking, wait for an edit/answer

edit.

First, why you are using "LEN" , hmm ? i thought that it was necessary to do in MOTD only or old menu

Reason for 33 times 010000000... :

PHP Code:
                for(new ii=0ii<33ii++)
                    
iLen += formatex(loaddata[iLen], (5120 iLen), "%d"g_data[id][i][ii]) 
Look, if you want save to "loaddata" g_data, just use:
PHP Code:
formatex(loaddatacharsmax(loaddata), "^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^" ^"%s^""g_data[id][0], 
g_data[id][1], g_data[id][2], g_data[id][3], g_data[id][4], g_data[id][5]) 
then write on line this "loaddata"and check the results.

If you save like this, you will not see "010000000000....." only "01" ( i think)
</span></span>
sorry, I must see "010000000000...", not "01".
yl2401 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-07-2015 , 12:25   Re: About string question
Reply With Quote #23

I don't understand why you need all of those zeros. Your menu has choices of 1, 2, & 3. When you select either of them it rotates the value +1 in a cycle of 0-2. So you should only need to store 3 sets of values, so "210" for example, with selection 1=2, 2=1, 3=0
__________________
Bugsy is offline
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 08-07-2015 , 12:29   Re: About string question
Reply With Quote #24

okey, so if you want to print only 0/1/2 you have to only do this:
PHP Code:
new variable str_to_num(g_data[id][X][X]) 
where X is the value what you want for.

//sorry bugsy, i dont saw your message ; p

Last edited by grs4; 08-07-2015 at 12:30.
grs4 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-07-2015 , 18:47   Re: About string question
Reply With Quote #25

There is no data.ini used, I used nvault to store the survey responses using the players steam id as the key. If you prefer, the players name can be stored along with the survey data. Also, you do not need a Submit command, the data is automatically loaded/saved when they connect/disconnect.
PHP Code:
#include <amxmodx>
#include <nvault>

new const Version[] = "0.1";

const 
MAXPLAYERS 32;

enum _:Surveys
{
    
Survey1,
    
Survey2,
    
Survey3
}

new const 
SurveyBitsSurveys ] = 
{
    
0b000011,
    
0b001100,
    
0b110000
};
    
new 
g_SurveyMAXPLAYERS ] , g_szAuthIDMAXPLAYERS ][ 34 ] , g_Vault;

public 
plugin_init() 
{
    
register_plugin"Survey" Version "bugsy" );
    
    
g_Vault nvault_open"survey_vault" );
    
    
register_clcmd"say survey" "Survey" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid )
{
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
    
    
g_Surveyid ] = nvault_getg_Vault g_szAuthIDid ] );
}

public 
client_disconnectid )
{
    new 
szSurvey];
    
    
num_to_strg_Surveyid ] , szSurvey charsmaxszSurvey ) );
    
nvault_setg_Vault g_szAuthIDid ] , szSurvey );
}

public 
Survey(id)
{
    static 
option[256]
    new const 
SurveyResult[][] = { "A" "B" "C" };
    
    new 
iMenu menu_create("\rSurvey1""handle_Survey1")
    
    
formatex(optioncharsmax(option), " \yQuestion 1: ABC?^n \wYour Choose is: \r%s" SurveyResultGetSurveyValueid Survey1 ) ] )
    
menu_additem(iMenuoption"1")
    
formatex(optioncharsmax(option), " \yQuestion 2: ABC?^n \wYour Choose is: \r%s" SurveyResultGetSurveyValueid Survey2 ) ] )
    
menu_additem(iMenuoption"2")
    
formatex(optioncharsmax(option), " \yQuestion 3: ABC?^n \wYour Choose is: \r%s^n" SurveyResultGetSurveyValueid Survey3 ) ] )
    
menu_additem(iMenuoption"3")
    
menu_additem(iMenu" \rSubmit""4")
    
    
menu_setprop(iMenuMPROP_EXITNAME"Exit")
    
menu_setprop(iMenuMPROP_EXITMEXIT_ALL)
    
    
menu_display(idiMenu)
    
    return 
PLUGIN_HANDLED
}
    
public 
handle_Survey1(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
Data[6], Name[64] , AccessCallbackiKey
    
    menu_item_getinfo
menu item Access Data ,Name 63 Callback )
    
    
iKey str_to_numData ) - 1;
    
    if ( 
<= iKey <= )
    {
        
StoreSurveyid iKey );
        
Survey(id)
    }
    
    
menu_destroy(menu)
    
    return 
PLUGIN_HANDLED
}

public 
StoreSurveyid SurveyNum )
{
    new 
iCurrentVal GetSurveyValueid SurveyNum );
    
    
g_Surveyid ] &= ~( 0b11 << ( SurveyNum ) );
    
g_Surveyid ] |= ( ( iCurrentVal ) % ) << ( SurveyNum );
}

public 
GetSurveyValueid SurveyNum )
{
    return ( 
g_Surveyid ] & SurveyBitsSurveyNum ] ) >> ( SurveyNum );

__________________

Last edited by Bugsy; 08-08-2015 at 10:00.
Bugsy is offline
yl2401
Member
Join Date: Nov 2011
Old 08-08-2015 , 10:09   Re: About string question
Reply With Quote #26

OK, Thank you!!
Please help me to solve these cases.

Case 1:
I want the more new data in the end, the more old data in the front, or even deleted when the string is full. How to do it?

data.ini:
"Name" "127.0.0.1"
"Name2" "127.0.0.1"
"Name3" "127.0.0.1"
"Name4" "127.0.0.1"
"Name5" "127.0.0.1"

like this:
g_name[id][0] = "Name3"
g_name[id][1] = "Name4"
g_name[id][2] = "Name5"
------------------------------
Case 2:

g_name[id][0] = "Name2"
g_name[id][1] = "Name3"
g_name[id][2] = "" (No data)

How to read the last name(Name3) from g_name[id]?
Like g_name[ id ][ strlen(g_name[id][0]) ]?
I hope strlen(g_name[id][0]) returns 1.

Thank you very much!!!!!
yl2401 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-08-2015 , 10:27   Re: About string question
Reply With Quote #27

You are thinking about this the wrong way. Don't be concerned with how the data is in the file, functions can be created that can display it as you want it in a specific order.
__________________
Bugsy is offline
yl2401
Member
Join Date: Nov 2011
Old 08-09-2015 , 13:34   Re: About string question
Reply With Quote #28

Quote:
Originally Posted by Bugsy View Post
You are thinking about this the wrong way. Don't be concerned with how the data is in the file, functions can be created that can display it as you want it in a specific order.
Oh, how should I modify? THX!!!!!!
yl2401 is offline
yl2401
Member
Join Date: Nov 2011
Old 08-10-2015 , 07:53   Re: About string question
Reply With Quote #29

Quote:
Originally Posted by Bugsy View Post
You are thinking about this the wrong way. Don't be concerned with how the data is in the file, functions can be created that can display it as you want it in a specific order.
Can I use this?
PHP Code:
new iLine file_size(szFile1), iTextLength
while(read_file(szFileiLineszDatacharsmax(szData), iTextLength) != 0

Last edited by yl2401; 08-10-2015 at 07:53.
yl2401 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-10-2015 , 09:26   Re: About string question
Reply With Quote #30

No
__________________
Bugsy 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 13:02.


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