Force name
#1

Is it possible to script something that when you select a class (Grove or Ballas). Lets say we choose Grove, and then my name will change to [Grove]Galcio automatically. And if I choose Ballas my name will get changed to [Ballas]Galcio. Or is there any FS out there that do this thing?
Reply
#2

pawn Code:
if(GetPlayerTeam==TEAM_BALLAS)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
new newname[128];
format(newname, sizeof(newname), "[Ballas]%s", pname);
SetPlayerName(playerid, newname);
return 1;
}
You can do that for every team.

Cheers.
Reply
#3

I'm a bit of a noob at his.. but where do I put 'em? This is my code (where I think I should put it :P):
pawn Code:
SetPlayerTeamFromClass(playerid, classid)
{
        if (classid == 0)
        {
                gTeam[playerid] = TEAM_GROVE;
        }
        else
        {
                gTeam[playerid] = TEAM_BALLA;
        }
        SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
        SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
        SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
        return 1;
}
Reply
#4

Put it under OnPlayerSpawn. Just like this here:

pawn Code:
public OnPlayerSpawn(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
new newname[128];

if(GetPlayerTeam==TEAM_BALLA)
{
format(newname, sizeof(newname), "[Balla]%s", pname);
}

if(GetPlayerTeam==TEAM_GROVE)
{
format(newname, sizeof(newname), "[Grove]%s", pname);
}

SetPlayerName(playerid, newname);

return 1;
}
Cheers.
Reply
#5

Thanks for helping me out, but my code got a bit of messy now..

pawn Code:
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
new newname[128];

if(GetPlayerTeam==TEAM_BALLA)
{
format(newname, sizeof(newname), "[Balla]%s", pname);
}

if(GetPlayerTeam==TEAM_GROVE)
{
format(newname, sizeof(newname), "[Grove]%s", pname);
}

SetPlayerName(playerid, newname);
return 1;
}
And it gives me this error:
Quote:

error 076: syntax error in the expression, or invalid function call
error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

I appreciate the help alot!
Reply
#6

Which lines cause the errors?

#EDIT: lol i see.... heres the sollution:
pawn Code:
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
new newname[128];

if(GetPlayerTeam(playerid)==TEAM_BALLA)
{
format(newname, sizeof(newname), "[Balla]%s", pname);
}

if(GetPlayerTeam(playerid)==TEAM_GROVE)
{
format(newname, sizeof(newname), "[Grove]%s", pname);
}

SetPlayerName(playerid, newname);
return 1;
}
I just forgot the parameters of GetPlayerTeam

This should work

Cheers.
Reply
#7

230, 235

pawn Code:
if(GetPlayerTeam==TEAM_BALLA)

if(GetPlayerTeam==TEAM_GROVE)
Edit: Checking!
Reply
#8

It compiled with no problems, but when I enter the server and choose the Balla team, but name goes like this: [Grove]Galcio.
Probably a simple edit in the script! But if you know how to fix, please reply.
Reply
#9

Are you sure, that you set the teams correctly? If yes, try this, it might help:

pawn Code:
public OnPlayerSpawn(playerid)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
new newname[128];

if(GetPlayerTeam==TEAM_BALLA)
{
format(newname, sizeof(newname), "[Balla]%s", pname);
}

else if(GetPlayerTeam==TEAM_GROVE)
{
format(newname, sizeof(newname), "[Grove]%s", pname);
}

SetPlayerName(playerid, newname);

return 1;
}
Reply
#10

Quote:
Originally Posted by DeathOnaStick
pawn Code:
if(GetPlayerTeam==TEAM_BALLAS)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
new newname[128];
format(newname, sizeof(newname), "[Ballas]%s", pname);
SetPlayerName(playerid, newname);
return 1;
}
You can do that for every team.

Cheers.
ever heard of
MAX_PLAYER_NAME

it is = to 20

which means u use to much cells which is to much ressources n lames the server
cuz the file gets bigger n bigger n the server neads to read more unused stuff
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)