How to get name from score
#1

hi all i am trying to make it that when a player gets a score of say 100 it lets all players on the server know that player [name] is now part of the ministry say the important bit is getting it so the player gets there name in it using the %s stuff but i think i have gone totally wrong and if anyone can fix it so it works but also explain what to do it wud be great

so basically as soon as a player reaches 100 score it says to all players such abiody is now part of the ministry



pawn Код:
//===============================================Rank Bonus======================================================//
forward Bonus(playerid);
public Bonus(playerid)
{
    if(GetPlayerScore(playerid) >= 500)//General of the army
    {
   
   
    new szPlayerName[MAX_PLAYER_NAME], szMessage[74];
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);

format(szMessage, sizeof(szMessage), "%s is now a member of the ministry ", szPlayerName);
SendClientMessageToAll(0xff0000FF, szMessage);  // Replace 0 with the colour
}
    GivePlayerMoney(playerid, 500000);//[EDITABLE]
    return 1;
    }
Reply
#2

pawn Код:
forward Bonus(playerid);
public Bonus(playerid)
{
    if(GetPlayerScore(playerid) == 100)//General of the army
    {
        new szPlayerName[MAX_PLAYER_NAME], szMessage[74];
        GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);

        format(szMessage, sizeof(szMessage), "%s is now a member of the ministry ", szPlayerName);
        SendClientMessageToAll(0xff0000FF, szMessage);  // Replace 0 with the colour
    }
    GivePlayerMoney(playerid, 500000);//[EDITABLE]
    return 1;
}
not sure if it will work but another way is

1.open script.
2.press ctrl + h.
3.Search for: SetPlayerScore, Replace with: N_SetPlayerScore
4.Replace all.
5. Paste this into script.

pawn Код:
stock N_SetPlayerScore(playerid, score)
{
    new oldscore= GetPlayerScore(playerid);
    SetPlayerScore(playerid, score);
    OnPlayerScoreChange(playerid, oldscore, score);
    return 1;
}

forward OnPlayerScoreChange(playerid, oldscore, newscore);
public OnPlayerScoreChange(playerid, oldscore, newscore)
{
    if(newscore == 100)
    {
        new szPlayerName[MAX_PLAYER_NAME], szMessage[74];
        GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
        format(szMessage, sizeof(szMessage), "%s is now a member of the ministry ", szPlayerName);
        SendClientMessageToAll(0xff0000FF, szMessage);
    }
    return 1;
}
And use N_SetPlayerScore from now on
Reply
#3

pawn Код:
new Ministry[MAX_PLAYERS];

public OnPlayerDeath(playerid, killerid, reason)
{
    if(Ministry[killerid] != 1)
    {
        do your shit here to check like getscore n shit
    }
}
public OnPlayerConnect(playerid)
{
    if(GetPlayerScore(playerid) >= 500)
    {
        Ministry[playerid] = 1;
    }
    if(GetPlayerScore(playerid) < 500) Ministry[playerid] = 0;
}
Reply
#4

pawn Код:
#define COLOR_WHITE /*color hex here*/

new bool:IsMinistry[MAX_PLAYERS];

if(GetPlayerScore(playerid0 >= 100) && IsMinistry[playerid] == false)
{
  new output[128];
  new playername[MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername);
  format(output, sizeof(output), "%s is now a member of the ministry.", playername);
  SendClientMessageToAll(COLOR_WHITE, output);
  IsMinistry[playerid] = true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)