retrieving nickname

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

retrieving nickname

Post by Art »

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: Select all

   	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.
elz
Posts: 3
Joined: Mon Nov 21, 2005 8:10 pm

Post by elz »

Code: Select all

char nameBuffer[50];
sceUtilityGetSystemParamString(PSP_SYSTEMPARAM_ID_STRING_NICKNAME, nameBuffer, 50);
printf(nameBuffer);
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

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.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

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: Select all

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;
			}
}
polomint
Posts: 5
Joined: Sat Mar 11, 2006 12:25 am
Location: Colne, Lancashire, UK
Contact:

Post by polomint »

Why not use summat like this instead. it returns true if the nick is correct.

Code: Select all


// 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: Select all

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, :)
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

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.
Post Reply