[HELP] How to use unlimited syntaxes using { Float, _ }: ...
#1

Well like the title says, how do do this ?
I have a peace of code on my your sql include using this method:

Function:
pawn Код:
stock yoursql_insert(table[],values[])
{
    new query[256];format(query,sizeof query,"INSERT INTO %s (%s) VALUES (%s)",table,GetStructure(table),values);
    return mysql_query(query,-1,-1,connection);
}
Usage:
pawn Код:
new string[128];
format(string,sizeof string,"'%s',%i,%i",yoursql_escape_string(PlayerInfo[playerid][UserName]),PlayerInfo[playerid][money],PlayerInfo[playerid][score]);
yoursql_insert("users",string)
Which i want to convert to:

Usage:
pawn Код:
yoursql_insert("users","sii",yoursql_escape_string(PlayerInfo[playerid][UserName]),PlayerInfo[playerid][money],PlayerInfo[playerid]);
I know this can be done using getargs(), setargs() and numargs(), i tried it but i just cant get it to work. My test code :http://pastebin.com/CYz6FR80
Reply
#2

You might take a look at this: https://sampforum.blast.hk/showthread.php?tid=77000
Reply
#3

I tried... but my function is writing the mod idiot things D:

Callback:
pawn Код:
yoursql_insert("Users","ssiii",pName,inputtext,GetPlayerScore(playerid),GetPlayerMoney(playerid),PlayerInfo[playerid][level]);
Function:
pawn Код:
stock yoursql_insert(table[],type[],{ Float, _ }: ...)
{
    /*new query[256];format(query,sizeof query,"INSERT INTO %s (%s) VALUES (%s)",table,GetStructure(table),values);
    return mysql_query(query,-1,-1,connection);*/

    for(new a = 0;a<numargs();a++)
    {
        switch(type[a])
        {
            case 's':
            {
                new temp[32];
                for(new b = 0;b<32;b++)
                {
                    if(!strlen(temp))
                    {
                        format(temp,sizeof temp,"%s",getarg(a +2,b));
                    } else format(temp,sizeof temp,"%s%s",temp,getarg(a +2,b)); //+2 because else its start reading from Table[] ?
                }
                printf("STR DEBUG: %s",temp);
            }
        }
    }
}
Console:
Код:
[20:42:22] STR DEBUG: Gamerј
[20:42:22] STR DEBUG: tamerјeamerјsamerјtame
its all random :S, this time it had the password good, but the username was still fcked up
Код:
[20:40:38] STR DEBUG: GamerTј
[20:40:38] STR DEBUG: test1337
after another reloadfs it even showed some source code :S
Код:
[20:33:43] STR DEBUG: GamerЊњ°я°PgИxrД
[20:33:43] STR DEBUG: wachtwoordPlayerlevelPassword%stest133
Код:
[20:50:54] STR DEBUG: Gamer<ј
[20:50:54] STR DEBUG: test
[20:50:54] STR DEBUG: 
[20:50:54] STR DEBUG: OnPlayerCommandReceivedOnPlay
Reply
#4

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)