playername
#1

Hey guys. When I use a message in a string where my name should be displayed in and there are more players online it's very buggy.
Instead of:

Welcome bartje01 it says welcome artje01

I use it like this:

on top:
pawn Код:
new Name[MAX_PLAYER_NAME]
onplayerconnect
pawn Код:
GetPlayerName(playerid, Name, sizeof(Name));
format(String,sizeof(String),"Welcome to {FF0000}Infinity Roleplay {00FF00}%s",Name[playerid]);
SendClientMessage(playerid,COLOR_GREEN,String);
What is wrong?
Thanks
Reply
#2

Remove [playerid] from Name
Reply
#3

Ok ty that worked. But how will I do it here?
I don't want to use GetPlayerName everywhere.

pawn Код:
COMMAND:makeadmin(playerid,params[])
{
    new level,id;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_GREY,"You're not an Infinity RCON admin, you're not allowed to use this.");
    if(sscanf(params,"ud",id,level)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /makeadmin [playerid] [level]");
    format(String,sizeof(String),"%s made you a admin level %d",Name[playerid],level);
    SendClientMessage(id,COLOR_ORANGE,String);
    format(String,sizeof(String),"You've made %s admin level %d",Name[id],level);
    SendClientMessage(playerid,COLOR_ORANGE,String);
    PlayerInfo[id][pAdminLevel] = level;
    return 1;
}
Reply
#4

This..?

Add this to the end of your script. Then use it everytime whenever a player's name is required.
pawn Код:
stock GetName(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername,sizeof(playername));
    return playername;
}
So, whenever you format a string, just add GetName(id).. No need for GetPlayerName again & again..
pawn Код:
format(String,sizeof(String),"%s made you a admin level %d",GetName(playerid),level);
Reply
#5

Oooh I see. Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)