[HELP] RemoveUnderScore
#1

I got this function called RemoveUnderScore and it works like the sendername it just deletes the Under Score [_] of the player who sent the message.

The functions works like a charm but I need this function to giveplayerid too, so for an example:

format(string, sizeof(string), "** %s gives BlahBlah to %s", RemoveUnderScore(playerid) [HERE]);

There it says [HERE] should the giveplayerid be, but I want it to work like the sendername, it should removes the Under Score on it too.

This is how the function looks like:

Код:
stock RemoveUnderScore(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
Thanks
Reply
#2

Use the first one if you use ReturnUser, second if not
pawn Код:
stock RemoveUnderScore(playerid, target)
{
    new targetid = ReturnUser(target);
    new name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
    GetPlayerName(targetid, targetname, sizeof targetname);
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
        if(targetname[i] == '_') targetname[i] = ' ';
    }
    return name, targetname;
}

pawn Код:
stock RemoveUnderScore(playerid, target)
{
    new targetid = strval(target);
    new name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
    GetPlayerName(targetid, targetname, sizeof targetname);
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
        if(targetname[i] == '_') targetname[i] = ' ';
    }
    return name, targetname;
}
Reply
#3

Quote:
Originally Posted by Claude
Посмотреть сообщение
Use the first one if you use ReturnUser, second if not
pawn Код:
stock RemoveUnderScore(playerid, target)
{
    new targetid = ReturnUser(target);
    new name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
    GetPlayerName(targetid, targetname, sizeof targetname);
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
        if(targetname[i] == '_') targetname[i] = ' ';
    }
    return name, targetname;
}

pawn Код:
stock RemoveUnderScore(playerid, target)
{
    new targetid = strval(target);
    new name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
    GetPlayerName(targetid, targetname, sizeof targetname);
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
        if(targetname[i] == '_') targetname[i] = ' ';
    }
    return name, targetname;
}
Over 50 number of arguments does not match definition, one argument type mismatch (argument 1) and a symbol is never used: "target". When I'm using this, I put RemoveUnderScore(playerid) as you can see on my example, can taht be the reason, do I have to use another code? And yes, I'm using ReturnUser.
Reply
#4

Sorry for bumping, but this is a urgent need, it's one of my last problems I got.
Reply
#5

pawn Код:
format(string, sizeof(string), "** %s gives BlahBlah to %s", RemoveUnderScore(playerid),RemoveUnderScore(giveplayerid));
Perhaps?
Reply
#6

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
pawn Код:
format(string, sizeof(string), "** %s gives BlahBlah to %s", RemoveUnderScore(playerid),RemoveUnderScore(giveplayerid));
Perhaps?
Now it says that RemoveUnderScore(playerid): number of arguments does not match definition

And I got around 50 of the RemoveUnderScore(playerid) in my script...
Reply
#7

For example, this is the first Error Line in my script:

Код:
		    	format(string, sizeof(string), "%s says: %s", RemoveUnderScore(playerid), text);
		    	ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
And yeah, number of arguments does not match definition
Reply
#8

I use something like this..

pawn Код:
new name[MAX_PLAYER_NAME];
new string[64];
GetPlayerName(playerid,name,sizeof(name));
name[strfind(name,"_")] = ' ';
format(string,sizeof(string),"Your name is %s",name);
SendClientMessage(playerid,COLOR_GREY,string);
It works and name is without underscore. And btw, its easier, you don't need to write some hard code to gain it. It just requests one line.
Reply
#9

Quote:
Originally Posted by silvis123
Посмотреть сообщение
I use something like this..

pawn Код:
new name[MAX_PLAYER_NAME];
new string[64];
GetPlayerName(playerid,name,sizeof(name));
name[strfind(name,"_")] = ' ';
format(string,sizeof(string),"Your name is %s",name);
SendClientMessage(playerid,COLOR_GREY,string);
It works and name is without underscore. And btw, its easier, you don't need to write some hard code to gain it. It just requests one line.
Undefined Symbol "Name"
Reply
#10

Hmm.. Maybe i just made a mistake, but i use this in my GM, it works fine without any errors or warnings.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)