SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 02/12/2009, 09:05 PM   #11
tom_jonez
Huge Clucker
 
Join Date: Dec 2007
Posts: 219
Reputation: 0
Default Re: [HELP] #DEFINE Question

@mave
Tried, but Im getting these damn index errors still...
pawn Code:
#define variable(%0,%1) \
    Players[%0][%1]
    #define vname(%0) \
      userTableStr[%0]
    format(variable(playerid,vname(fval)),256,"%s",field); // Index errors given on this line
    printf("%s is now stored as %s for player id (%i).",field,vname(fval),playerid);
    fval ++;
    while(samp_mysql_strtok(field, "|", "")==1)
    {
        if(sizeof(Players[][vname(fval)])<2 && IsNumeric(Players[][vname(fval)]){
            Players[playerid][vname(fval)] = strval(field);
        }else{
          format(variable(playerid,vname(fval)),sizeof(Players[][vname(fval)]),"%s",field);
        }
      printf("%s is now stored as %s for player id (%i).",field,vname(fval),playerid);
      fval ++;
    }
Any idea on what to do? Heres the userTableStr array:
pawn Code:
new userTableStr[22][] =
{
    "username",
    "password",
    "email",
    "hideemail",
    "datejoined",
    "id",
    "loggedin",
    "score",
    "money",
    "bankstate",
    "adminlevel",
    "regular",
    "armyaccess",
    "robrank",
    "lastseen",
    "dlicense",
    "plicense",
    "dinstructor",
    "pinstructor",
    "bannedby",
    "bantime",
    "banreason"
};


@Malice
Im trying to automatically unload values from a mysql table and to store them in the players variable array, i need to write out the actual cell to store it in. In this case, Players[playerid][username] and I can't figure out how to...
tom_jonez is offline  
Old 02/12/2009, 09:17 PM   #12
lolumadd
Huge Clucker
 
Join Date: Sep 2009
Posts: 350
Reputation: 8
Default Re: [HELP] #DEFINE Question

pawn Code:
new Print = true;


#define var do{new _00string[128]; format(_00string,sizeof(_00string),"%s", username[playerid]); print(_00string);} while(Print == true)
__________________
lolumadd is offline  
Old 02/12/2009, 09:19 PM   #13
Malice
Big Clucker
 
Join Date: Jul 2007
Posts: 105
Reputation: 0
Default Re: [HELP] #DEFINE Question

Edit: nvm....
Malice is offline  
Old 02/12/2009, 09:22 PM   #14
tom_jonez
Huge Clucker
 
Join Date: Dec 2007
Posts: 219
Reputation: 0
Default Re: [HELP] #DEFINE Question

Quote:
Originally Posted by lolumadd [cod5server.tk
]
pawn Code:
new Print = true;


#define var do{new _00string[128]; format(_00string,sizeof(_00string),"%s", username[playerid]); print(_00string);} while(Print == true)
u realize thatll print the username continuously?
tom_jonez is offline  
Old 02/12/2009, 09:59 PM   #15
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,896
Reputation: 118
Default Re: [HELP] #DEFINE Question

Quote:
Originally Posted by R4nk3d
How would i define 1 word as a variable?

ex:
Code:
new var[64];
format(var,64,"%s",username[playerid]); //in this case, R4nk3d
#define a "var"
So when I type print(var) it prints R4nk3d.
Have you already tried this? If so, make sure username[playerid] stores GetPlayerName function.
Also, try this:
pawn Code:
new var[64];
format(var, 64, "%s", username[playerid]);
#if defined a
#undef a
#define a var
#endif
Grim_ is offline  
Old 02/12/2009, 10:18 PM   #16
tom_jonez
Huge Clucker
 
Join Date: Dec 2007
Posts: 219
Reputation: 0
Default Re: [HELP] #DEFINE Question

Im not worried about the actual value. I just need the definition to write whatever cell of the array i pick into the PAWNO code.

Look at the above enums. I want it to type into pawno:
format(var(playerid,vname(fval)),sizeof(var(player id,vname(fval))),"%s",field);
and i want it to say to itself when its actually running the loop:
format(Players[playerid][username],sizeof(Players[playerid][username]),"%s",field);
tom_jonez is offline  
Old 02/12/2009, 10:52 PM   #17
yezizhu
Gangsta
 
yezizhu's Avatar
 
Join Date: Nov 2007
Location: Shenzhen,China
Posts: 640
Reputation: 2
Default Re: [HELP] #DEFINE Question


Why use macro, use function.
pawn Code:
stock pUser(playerid){
  return Players[playerid][pusername];//you variable setting
}
stock pUseremail(playerid){
  return Players[playerid][puseremail];
}
I hope I catch what u mean.
yezizhu is offline  
Old 02/12/2009, 11:49 PM   #18
tom_jonez
Huge Clucker
 
Join Date: Dec 2007
Posts: 219
Reputation: 0
Default Re: [HELP] #DEFINE Question

I tried:

pawn Code:
stock ListpInfo(cell)
{
return userTableStr[cell];
}
and then:
Code:
	format(Players[playerid][ListpInfo(fval)],256,"%s",field);
but i get the error:
Code:
C:\Inetpub\wwwroot\lvrcr\gameserver\gamemodes\debug.pwn(1862) : error 033: array must be indexed (variable "ListpInfo")
tom_jonez is offline  
Old 03/12/2009, 05:24 AM   #19
Streetplaya
Gangsta
 
Join Date: Nov 2007
Posts: 603
Reputation: 1
Default Re: [HELP] #DEFINE Question

I guess you mean the sizeof problem?? Look up pawn-lang.php perhaps?
Streetplaya is offline  
 

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
gl_property define question Jochemd Help Archive 0 29/04/2010 03:17 PM
format and #define question toby` Help Archive 4 12/03/2010 12:42 PM
How do i define this?? HELP Arsham7 Help Archive 5 11/03/2010 07:31 PM
Using Colon instead of Paren. to define params in #define Daren_Jacobson Help Archive 1 05/11/2009 11:48 PM
[Solved] Using a #define in a #define Extremo Help Archive 6 16/10/2009 10:25 AM


All times are GMT. The time now is 10:07 AM.


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