| View previous topic :: View next topic |
| Author |
Message |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Fri Mar 31, 2006 4:54 pm Post subject: retrieving nickname |
|
|
Hi Guys,
I want to retrieve the system nickname "Art" in the shortest code
possible. The routine doen't need to accomodate any longer names.
| Code: |
deleted embarrasing sample :) |
What's wrong with this?
It prints blank space to the screen except for the ":" and "Nickname" strings.
Cheers, Art.
Last edited by Art on Fri Mar 31, 2006 10:15 pm; edited 1 time in total |
|
| Back to top |
|
 |
elz
Joined: 21 Nov 2005 Posts: 3
|
Posted: Fri Mar 31, 2006 8:21 pm Post subject: |
|
|
| Code: |
char nameBuffer[50];
sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, nameBuffer, 50);
printf(nameBuffer);
|
|
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Fri Mar 31, 2006 10:16 pm Post subject: |
|
|
Thanx a lot nameBuffer, that worked a treat :)
I wonder why more homebrew programs aren't personalised this way.
It seems trivial when Sony does it with a game, but would be a new look
for homebrew. |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Apr 01, 2006 4:04 pm Post subject: |
|
|
Thanx. Well at least as a 'noob' I did something for myself.
Learned the syntax for 1 whole utility function after an hour of stuffing around.
I wanted a true or false condition, I don't know if this is the best way,
and this is homebrew so I access global variables within functions all the time.
| Code: |
int bob = 0;
char namebuffer[50];
// bob will equal 1 if PSP nickname is "Bob".
void check_nick() {
char nick[] = "Bob";
sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, namebuffer, 50);
if(strcmp(namebuffer,nick)==0) {
bob = 1;
}
}
|
|
|
| Back to top |
|
 |
polomint
Joined: 11 Mar 2006 Posts: 5 Location: Colne, Lancashire, UK
|
Posted: Sat Apr 01, 2006 6:52 pm Post subject: |
|
|
Why not use summat like this instead. it returns true if the nick is correct.
| Code: |
// check_nick will return true if name is correct
bool check_nick(char* nick) {
char namebuffer[50];
sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, namebuffer, 50);
if(strcmp(namebuffer,nick)==0) {
return true;
} else {return false};
}
|
use it as so ...
| Code: | char name[] = "bob";
bool ok = check_nick(name);
if (ok)
{
// name is ok
} else
{
// name is not ok
} |
Bear in mind, I think i've coded it right, haven't tested it tho, :) |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Apr 01, 2006 7:01 pm Post subject: |
|
|
Ok, thanks, I'm still learning as you can see.
I wanted to post something that did the job in case someone else
searched about it later on.
There are already small samples floating around checking MAC Address,
but not the nickname.
Art. |
|
| Back to top |
|
 |
|