2 Problems (+REP Who Fixes Them All)
#1

Hello Guys,So The 1st Problem Is: I Made A Timer To All Players Under Ongamemodeinit Callback:
pawn Код:
SetTimer("KillingScore", 1440000, true);
And It's Public Function:
pawn Код:
forward KillingScore();
public KillingScore()
{
     new highestmoney = GetHighestKiller(); // Get the highest holder of money.
     new pnamez[MAX_PLAYER_NAME]; // Declare the variable which will hold the player name in array.
     new str[64]; // Declare the variable which will hold the message in array.
     if(highestmoney != INVALID_PLAYER_ID) // Check if he is a real player or -1.
     {
       for( new i = 0; i < MAX_PLAYERS; i ++ )
       {
        GetPlayerName(highestmoney, pnamez, sizeof(pnamez)); // Get the player's name.
        format(str, sizeof(str), "Congratulations!, You Are The {FF0000}Killer {FFEE00}Of The Day!"); // Format the string with message.
        SendClientMessage(i, 0xFFEE00FF, str); // Show the message.
       }
     }
}
When The Timer Ends,It Supposes To Send The Str Message To The Player Who Has The Highest Variable (KillerScore[MAX_PLAYERS]) And You Will See What Is That Variable Used On:
pawn Код:
stock GetHighestKiller()
{
    new
        money,
        player = -1
    ;
    for (new i = 0, mx = GetMaxPlayers(); i != mx; ++i)
    {
        if (IsPlayerConnected(i))
        {
            if (KillerScore[i] > money)
            {
                player = i;
                money = KillerScore[i];
            }
        }
    }
    return player;
}
And Actually KillerScore Suppose To Be Increased +1 Each Time When The Killer Is Killing The Player,It's Putted Under OnPlayerDeath Callback:
pawn Код:
KillerScore[killerid] ++;
Well The Problem In It Is,That It Sends The Message To All Players.




2nd Problem Is:

That In /v Command,It Supposes To Create The Vehicle And Destroy The Old One,But It Only Creates The Vehicle At These Codes:
pawn Код:
COMMAND:v(playerid, params[])
{
    new vehname[32],color1,color2, getveh[MAX_PLAYERS], Message[128], pName26[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, 0xFF0000AA, "You Are Not A Moderator Or Higher Rank!");
    if(sscanf(params,"s[32]dd",vehname, color1, color2)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /v [vehicle [Name / ID]] [color1] [color2]");
    new vehicleID = GetVehicleModelIDFromName(vehname);
    if(vehicleID == (-1)) vehicleID = strval(vehname);
    if(!(400 <= vehicleID <= 611)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid vehicle ID/name");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    DestroyVehicle(getveh[playerid]);
    getveh[playerid] = CreateVehicle(vehicleID, x, y, z, 90, color1, color2, 60000);
    format(Message,sizeof(Message),"Successfully Spawned A Vehicle With Name/ID: {FFEE00}%s{FF00F7}.",vehname);
    SendClientMessage(playerid, 0xFF00F7FF, Message);
    PutPlayerInVehicle(playerid, getveh[playerid], 0);
    AdminVehicle[getveh[playerid]] = 1;
    if(PlayerInfo[playerid][pAdmin] > 0)
    {
          switch(PlayerInfo[playerid][pAdmin])
          {
          case 1: AdmRank = "Trial Moderator";
          case 2: AdmRank = "Moderator";
          case 3: AdmRank = "Master Moderator";
          case 4: AdmRank = "Trial Administrator";
          case 5: AdmRank = "Administrator";
          case 6: AdmRank = "Master Administrator";
          case 7: AdmRank = "Head Administrator";
          case 8: AdmRank = "Trusted Administrator";
          case 9: AdmRank = "Co-Owner";
          case 10: AdmRank = "Owner";
          }
    }
    foreach(Player, i)
    {
      if(PlayerInfo[i][pAdmin] > 0)
      {
         GetPlayerName(playerid, pName26, MAX_PLAYER_NAME);
         format(Message, sizeof(Message), "[ADM] The {FF0000}%s {FF5900}%s (%d) Has Spawned A Vehicle.",AdmRank, pName26, playerid), SendClientMessage(i, 0xFF5900FF, Message);
         print(Message);
      }
    }
    return 1;
}
Please Help If You Helped Me In Fixing Both 2 Problems You Will Have +REP.
Reply
#2

1st problem
pawn Код:
stock GetHighestKiller()
{
    new m;
    for(new i = 0 ; i <= MAX_PLAYERS ; i++)
    {
        if(KillerScore[i] > KillerScore[m])
        {
            m = i;
        }
    }
    return i;
}
forward KillingScore();
public KillingScore()
{
     new highestmoney = GetHighestKiller(); // Get the highest holder of money.
     new str[64]; // Declare the variable which will hold the message in array.
     if(highestmoney != INVALID_PLAYER_ID) // Check if he is a real player or -1.
     {
        format(str, sizeof(str), "Congratulations!, You Are The {FF0000}Killer {FFEE00}Of The Day!"); // Format the string with message.
        SendClientMessage(highestmoney, 0xFFEE00FF, str); // Show the message.
     }
}
Reply
#3

2nd
pawn Код:
getveh[MAX_PLAYERS] = -1;
COMMAND:v(playerid, params[])
{
    new vehname[32],color1,color2, Message[128], pName26[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, 0xFF0000AA, "You Are Not A Moderator Or Higher Rank!");
    if(sscanf(params,"s[32]dd",vehname, color1, color2)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /v [vehicle [Name / ID]] [color1] [color2]");
    new vehicleID = GetVehicleModelIDFromName(vehname);
    if(vehicleID == (-1)) vehicleID = strval(vehname);
    if(!(400 <= vehicleID <= 611)) return SendClientMessage(playerid, 0xFF0000AA, "Invalid vehicle ID/name");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    DestroyVehicle(getveh[playerid]);
    getveh[playerid] = CreateVehicle(vehicleID, x, y, z, 90, color1, color2, 60000);
    format(Message,sizeof(Message),"Successfully Spawned A Vehicle With Name/ID: {FFEE00}%s{FF00F7}.",vehname);
    SendClientMessage(playerid, 0xFF00F7FF, Message);
    PutPlayerInVehicle(playerid, getveh[playerid], 0);
    AdminVehicle[getveh[playerid]] = 1;
    if(PlayerInfo[playerid][pAdmin] > 0)
    {
          switch(PlayerInfo[playerid][pAdmin])
          {
          case 1: AdmRank = "Trial Moderator";
          case 2: AdmRank = "Moderator";
          case 3: AdmRank = "Master Moderator";
          case 4: AdmRank = "Trial Administrator";
          case 5: AdmRank = "Administrator";
          case 6: AdmRank = "Master Administrator";
          case 7: AdmRank = "Head Administrator";
          case 8: AdmRank = "Trusted Administrator";
          case 9: AdmRank = "Co-Owner";
          case 10: AdmRank = "Owner";
          }
    }
    foreach(Player, i)
    {
      if(PlayerInfo[i][pAdmin] > 0)
      {
         GetPlayerName(playerid, pName26, MAX_PLAYER_NAME);
         format(Message, sizeof(Message), "[ADM] The {FF0000}%s {FF5900}%s (%d) Has Spawned A Vehicle.",AdmRank, pName26, playerid), SendClientMessage(i, 0xFF5900FF, Message);
         print(Message);
      }
    }
    return 1;
}
Reply
#4

Thanks They Have Been Worked!!
Reply
#5

np bro
Reply


Forum Jump:


Users browsing this thread: