AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   encode base64 (https://forums.alliedmods.net/showthread.php?t=321986)

Nutu_ 03-10-2020 05:56

encode base64
 
Code:

error 017: undefined symbol "base64_encode"
error 088: number of arguments does not match definition

I've got these errors

base64.inc
PHP Code:

#include <amxmodx>

static const Codes64[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"

public Encode64(s[])
{
    new 
i=0,a=0,x=0,b=0,Result
    
for (i=1;i<strlen(s);i++) {
        
str_to_num(s[i])
        
256 x
        a 
8
        
while (>= 6) {
            
6
            x 
/ (<< a)
            
% (<< a)
            
Result += Codes64[1]
        }
    }
    if (
0) {
        
<< (a);
        
Result += Codes64[1];
    }
    return 
Result;
}

public 
Decode64(s[])
{
    new 
i=0,a=0,x=0,b=0,Result,ch[1]
    for (
1istrlen(s);i++) {
        for (new 
index 0Codes64[index]; index++)
            if (
s[i]==Codes64[index]) {
            
x=index-1
            
break
        }
        if (
>= 0) {
            
64 x
            a 
6
            
if (>= 8) {
                
8
                x 
>> a
                b 
% (<< a)
                
256
                Result 
+= num_to_word(x,ch,1)
            }
        }
        else exit;
    }
    return 
Result;


error line
PHP Code:

public get_graph_link(const szName[], szMotd[], iLen)
{
    static 
szName64[64];
    new 
iPos;
    
base64_encode(szNameszName64charsmax(szName64));
    
replace_all(szName64charsmax(szName64), "=""%%3D");
    
    
iPos += formatex(szMotd[iPos], iLen"<html><head></head><body bgcolor=^"#000000^"><div align=^"center^">");
    
iPos += formatex(szMotd[iPos], iLen"<strong><span style=^"color:#ffffff^">%s</span></strong><br /><br />", szName);
    
iPos += formatex(szMotd[iPos], iLen"<strong><span style=^"color:#ff0000;^">Day</span></strong><br />");
    
iPos += formatex(szMotd[iPos], iLen"<img src=^"http://www.gametracker.com/images/graphs/player_time.php?nameb64=%s&host=%s&start=-1d^" width=^"200^" height=^"150^"/><br /><br />",
    
szName64g_szIp);
    
iPos += formatex(szMotd[iPos], iLen"<strong><span style=^"color:#ff0000;^">Week</span></strong><br />");
    
iPos += formatex(szMotd[iPos], iLen"<img src=^"http://www.gametracker.com/images/graphs/player_time.php?nameb64=%s&host=%s&start=-1w^" width=^"200^" height=^"150^"/><br /><br />",
    
szName64g_szIp);
    
iPos += formatex(szMotd[iPos], iLen"<strong><span style=^"color:#ff0000;^">Month</span></strong><br />");
    
iPos += formatex(szMotd[iPos], iLen"<img src=^"http://www.gametracker.com/images/graphs/player_time.php?nameb64=%s&host=%s&start=-1m^" width=^"200^" height=^"150^"/><br /><br />",
    
szName64g_szIp);
    
iPos += formatex(szMotd[iPos], iLen"</div></body></html>");


PHP Code:

base64_encode(szNameszName64charsmax(szName64)); 


HamletEagle 03-10-2020 06:01

Re: encode base64
 
You have a function called Encode64 and one called Decode64 but you call something named base64_encode. Any bells ringing?

Nutu_ 03-10-2020 06:05

Re: encode base64
 
alright, thanks, i didnt even notice, i changed them and now i got this error
Code:

error 035: argument type mismatch (argument 1)
error 088: number of arguments does not match definition

same line, never edited something in .inc file before

HamletEagle 03-10-2020 06:30

Re: encode base64
 
Well, you didn't show how you changed and what you changed.

Nutu_ 03-10-2020 07:01

Re: encode base64
 
PHP Code:

#include <amxmodx>

static const Codes64[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"

public base64_encode(s[])
{
    new 
i=0,a=0,x=0,b=0,Result
    
for (i=1;i<strlen(s);i++) {
        
str_to_num(s[i])
        
256 x
        a 
8
        
while (>= 6) {
            
6
            x 
/ (<< a)
            
% (<< a)
            
Result += Codes64[1]
        }
    }
    if (
0) {
        
<< (a);
        
Result += Codes64[1];
    }
    return 
Result;
}

public 
base64_decode(s[])
{
    new 
i=0,a=0,x=0,b=0,Result,ch[1]
    for (
1istrlen(s);i++) {
        for (new 
index 0Codes64[index]; index++)
            if (
s[i]==Codes64[index]) {
            
x=index-1
            
break
        }
        if (
>= 0) {
            
64 x
            a 
6
            
if (>= 8) {
                
8
                x 
>> a
                b 
% (<< a)
                
256
                Result 
+= num_to_word(x,ch,1)
            }
        }
        else exit;
    }
    return 
Result;



HamletEagle 03-10-2020 15:55

Re: encode base64
 
So now you have a function called base64_encode that takes one argument and you call base64_encode(szName, szName64, charsmax(szName64)); (3 arguments). Read your code please.


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

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