Raised This Month: $ Target: $400
 0% 

Solved Help compare two strings


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 01-28-2019 , 09:19   Help compare two strings
Reply With Quote #1

Hi! I would like to compare two strings. Here is my code:

PHP Code:
stock LogInUser(id,givenpass[65])
{
    if(
gLoggedin[id] == 0){
        new 
userid get_user_userid(id)  
        
log_amx("%s - gpass || %s - user pass",givenpass,gPassword[id])
        if(
strcmp(gPassword[id],givenpass) == 0)
        {
            
chat_color(id,"!y[!gDR!y]!g Te-ai logat cu succes!")
            
gLoggedin[id] = 1
        
}
        else{
            
server_cmd("kick #%d parola incorecta!",userid)
        }
    }
    else{
        
chat_color(id,"!y[!gDR!y]!g Esti deja logat!")
        return 
PLUGIN_CONTINUE
    
}
    return 
PLUGIN_CONTINUE

In real life, givenpass = 1234
gPassword[id] = 1234
It takes the password from a file, here is the code for that:
PHP Code:
public LoadData(id){
    if(
is_user_bot(id))
    {
        return 
PLUGIN_HANDLED
    
}
    new 
Name[33]
    
get_user_name(id,Name,charsmax(Name))
    new 
path[128]
    
format(path,127,"%s%s.txt",gPathMaster,Name)
    if(!
file_exists(path))
    {
      
write_file(path,"PAROLA:",4)
    }
    new 
fopen(path,"r")
    new 
szLine[128]
    while(!
feof(f))
    {
        
fgets(f,szLine,charsmax(szLine))
        if(
contain(szLine,"PAROLA:") >-)
        {
            
replace_all(szLine,127,"PAROLA:","")
            
format(gPassword[id],64,"%s",szLine)
            
CheckPassword(id)
        }
    }
    if(
Credite[id] == 0)
    {
        
Credite[id] = 500000
    
}
    
fclose(f)
    return 
PLUGIN_HANDLED

Even tho the strings are completly the same, it still says that they are different.

Last edited by TudorLaLeagane; 01-28-2019 at 11:16.
TudorLaLeagane is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-28-2019 , 09:22   Re: Help compare two strings
Reply With Quote #2

equal or equali.
__________________









Last edited by CrazY.; 01-28-2019 at 09:23.
CrazY. is offline
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 01-28-2019 , 09:30   Re: Help compare two strings
Reply With Quote #3

It's the same output... The password is incorrect.
PHP Code:
 if(equal(gPassword[id],givenpass,64)) 
TudorLaLeagane is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 01-28-2019 , 10:00   Re: Help compare two strings
Reply With Quote #4

remove_quotes/trim.
__________________
eat1k is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-28-2019 , 10:22   Re: Help compare two strings
Reply With Quote #5

Also debug passwords.
__________________








CrazY. is offline
TudorLaLeagane
Junior Member
Join Date: Mar 2018
Old 01-28-2019 , 11:16   Re: Help compare two strings
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
Also debug passwords.
I had it debug...

But it works with Trim, so thank you all <3
TudorLaLeagane 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 07:31.


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