RemoveUnderScore giveplayerid
#1

Hello, I got a problem, how to remove the underscore from giveplayerid?

It works for RemoveUnderScore(playerid), but if I use RemoveUnderScore(giveplayerid) it gives an error, how to fix it?
Reply
#2

show code and error.
without it how can we help? Imagine.
Reply
#3

Post your code, we can't see the problem if we do not see the code.
Anyway, your could use this code below which works for me:
PHP код:
stock RemoveUnderScore(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,name,sizeof(name));
    for(new 
0MAX_PLAYER_NAMEi++)
    {
        if(
name[i] == '_'name[i] = ' ';
    }
    return 
name;

Reply
#4

Quote:
Originally Posted by whando
Посмотреть сообщение
Hello, I got a problem, how to remove the underscore from giveplayerid?

It works for RemoveUnderScore(playerid), but if I use RemoveUnderScore(giveplayerid) it gives an error, how to fix it?
Please can you explain more?
Reply
#5

May you show us the function you're using, please?

EDIT: OMG, you're really fast guys.
Reply
#6

Код:
	if(strcmp(cmd, "/setcarhp", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /setcarhp [playerid/PartOfName] [health]");
				return 1;
			}
			new CarHP;
			giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			CarHP = strval(tmp);
			GetPlayerName(playerid, sendername, sizeof(sendername));
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			if(PlayerInfo[playerid][pAdmin] >= 3)
			{
				if(IsPlayerInAnyVehicle(giveplayerid))
				{
				    SetVehicleHealth(GetPlayerVehicleID(giveplayerid), CarHP);
				    format(string, sizeof(string), "{FF0000}: %s has restored %s 's car to %d", RemoveUnderScore(playerid), giveplayer, CarHP);
				    SendAdminMessage(COLOR_RED, string);
				}
			}
		}
		return 1;
	}
I want the underscore from the giveplayer removed
Reply
#7

Not the command man, the function called RemoveUnderScore. Anyway, it should be:
pawn Код:
if(strcmp(cmd, "/setcarhp", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /setcarhp [playerid/PartOfName] [health]");
                return 1;
            }
            new CarHP;
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            CarHP = strval(tmp);
            GetPlayerName(playerid, sendername, sizeof(sendername));
            GetPlayerName(giveplayerid, giveplayerid, sizeof(giveplayerid));
            if(PlayerInfo[playerid][pAdmin] >= 3)
            {
                if(IsPlayerInAnyVehicle(giveplayerid))
                {
                    SetVehicleHealth(GetPlayerVehicleID(giveplayerid), CarHP);
                    format(string, sizeof(string), "{FF0000}: %s has restored %s 's car to %d", RemoveUnderScore(playerid), RemoveUnderScore(giveplayerid), CarHP);
                    SendAdminMessage(COLOR_RED, string);
                }
            }
        }
        return 1;
    }
Regards!
Reply
#8

Yes.. But at RemoveUnderScore(giveplayerid) I get an error.. Sorry, I'm a bit new to scripting .
Reply
#9

Yes man, but RemoveUnderScore is a function made by someone, it isn't a native. I mean, somewhere in your gamemodes/includes should be something as this:
pawn Код:
RemoveUnderScore(playerid) {
    //some code
}
I wanna see that function.

PD: don't worry, everything has a beginning.
Reply
#10

You mean this?


Код:
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;
}
Should I add this below it?
Код:
stock RemoveUnderScore(giveplayerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(giveplayerid,name,sizeof(name));
	for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
	if(name[i] == '_') name[i] = ' ';
}
	return name;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)