User name to real name
#1

Hi everybody!

I'm a noob in samp scripting, but i'm trying to learn it. I can send a client message to all if a player has been connected and I can also use a string to get the user name of the player in that message.

The new thing I'm trying no is to change that user name in their real name. This is the code I've got, and I'm sure it's wrong (because it doesn't work and the compiler gives a fault (warning 211: possibly unintended assignment) ) and I know i'm doing something wrong with the 'return-thing'.

Код:
public OnPlayerConnect(playerid)
{
        new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
        GetPlayerName(playerid, name, sizeof(name));
    
if(name="Aegidje")
{
name="Aegide";
return 1;
}

if(name="Elietje28")
{
name="Elias";
return 1;
}

if(name="vandenboerseppe")
{
name="Seppe";
return 1;
}

if(name="SmacksCharlie")
{
name="Karel";
return 1;
}

if(name="stabar")
{
name="Steven";
return 1;
}

if(name="Supertoby28")
{
name="Aдron";
return 1;
}


    format(string, sizeof(string), "%s is ingelogd. (=has been connected)", name);
    SendClientMessageToAll(COLOR_GREEN, string);
So what I think what's happening is: there is made a string, called 'name' and the user name is stored in the string. Then, it checks if the string is one of the user names of my friends (Aegidje, Elietje28, vandenboerseppe,...). If that's right, the string changes to their real names. The next part is sending the message with the string.

Each tutorial I watch or read, I don't understand the return-part. Is their someone who can explain me what I did wrong and what those returns exactly are?

Thanks!

Elietje28
Reply
#2

Wrong section.
Reply
#3

Thanks, but what do I have to do then? Do I have to make another callback?
Reply
#4

Wrong section and

pawn Код:
if(name="Aegidje")
{
name="Aegide";
}

else if(name="Elietje28")
{
name="Elias";
}

else if(name="vandenboerseppe")
{
name="Seppe";
}

else if(name="SmacksCharlie")
{
name="Karel";
}

else if(name="stabar")
{
name="Steven";
}

else if(name="Supertoby28")
{
name="Aдron";
}
Reply
#5

Okay, but what do you mean with wrong section?
Reply
#6

This should be in scripting help, not bug reports.
Reply
#7

@Swyft: Lol, you're an even bigger noob with Pawn than the topic starter.

@Eliet: You're correct about the names in the string. To compare strings, you need to use strcmp though. Also, the "return" function stops the whole function. Don't use it too early. Only use it at the end of your function, or if you want to stop the function earlier on.
Reply
#8

Quote:
Originally Posted by Basssiiie
Посмотреть сообщение
@Swyft: Lol, you're an even bigger noob with Pawn than the topic starter.

@Eliet: You're correct about the names in the string. To compare strings, you need to use strcmp though. Also, the "return" function stops the whole function. Don't use it too early. Only use it at the end of your function, or if you want to stop the function earlier on.
Just trying to help, and I don't believe that statement is true, but whatever helps you sleep at night.
Reply
#9

Quote:
Originally Posted by Swyft™
Посмотреть сообщение
Just trying to help, and I don't believe that statement is true, but whatever helps you sleep at night.
Fight the power.
Reply
#10

Okay, thanks everybody (and also Swyft, he just wants to help )

So this is the code I have now, but then, the string only changes to 'Aegide', even if I log in with 'Elietje28', 'vandenboerseppe',...

Код:
public OnPlayerConnect(playerid)
{

new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));
    
if(strcmp(name,"Aegidje",true))
{
name="Aegide";
}

else if(strcmp(name,"Elietje28",true))
{
name="Elias";
}

else if(strcmp(name,"vandenboerseppe",true))
{
name="Seppe";
}

else if(strcmp(name,"SmacksCharlie",true))
{
name="Karel";
}

else if(strcmp(name,"stabar",true))
{
name="Steven";
}

else if(strcmp(name,"Supertoby28",true))
{
name="Aдron";
}

    format(string, sizeof(string), "%s is ingelogd.", name);
    SendClientMessageToAll(COLOR_GREEN, string);
 	
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)