[Include] STInclude
#1

STInclude

Hello sampers. This include is my first and serves to facilitate the development. It's simple and useful.

Functions
  • KickWithMessage(playerid, color, const message[]) - Show a message and kick the player;
  • GetPlayerID(const name[]) - Get the ID of the player by name;
  • BanWithMessage(playerid, color, const message[]) - Show a message and ban the player;
  • SetPlayerMoney(playerid, money) - Set money;
  • SendMessageToPromt(playerid, const message[]) - Send a message to prompt with nick of the player;
  • SendPrivateMessage(playerid, rplayerid, color, const message[]) - Send a private message to other player;
  • GivePlayerScore(playerid, score) - Give player score;
  • pnome(playerid) - Geta o nome do player pelo ID;
  • SendClientMessageToOtherPlayers(playerid, color, const message[]) - Send a message to all players connected, except the playerid;
  • KillPlayer(playerid) - Kill player;
  • IsBike(vehicleid) - Checks whether the vehicle is a motorcycle or bicycle;
  • ClearChat() - Clear Chat;
  • Shutdown(seconds) - Shutdown the server;
  • Restart(seconds) - Restart the server;
  • ClearLog() - Clear server_log.txt;
Download
PasteBin
or Attached to this article
Reply
#2

Simple And Good keep it up
Reply
#3

pawn Код:
stock GetPlayerID(const Name[])
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(i, pName, sizeof(pName));
            if(strcmp(Name, pName, true)==0)
            {
                return i;
            }
        }
    }
    return -1;
}
- You shouldn't create a variable/array inside of a loop, so move new pName[MAX_PLAYER_NAME] and place it above the loop.

- You shouldn't use i < MAX_PLAYERS as if MAX_PLAYERS is defined as 32, it will never get to 32, 31 would be the max.


pawn Код:
stock pnome(playerid)
{
    new nomeplayer[50];
    GetPlayerName(playerid, nomeplayer, sizeof(nomeplayer));
    return nomeplayer;
}
Why is "nomeplayer" 's size 50? MAX_PLAYER_NAME is 24.


pawn Код:
stock GetPlayerIP(playerid)
{
    new ip[24];
    GetPlayerIp(playerid, ip, sizeof ip);
    return ip;
}
Why is ip's size 24? It should be 16.
Reply
#4

there's a lot of macros and you didn't program it well pnome? why its always get the player name from the function and not from parameter you need to set up, you need to work on it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)