dini and textdraws wont work...
#1

Hi all. I made this rank script and well... it doesnt work... heres the code:

pawn Код:
#include <a_samp>
#include <Dini>

#pragma unused strtok
#pragma unused ret_memcpy

#define USERFILE "Users/%s.ini"

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#define COLOR_GREY          0xAFAFAFAA
#define COLOR_GREEN         0x33AA33AA
#define COLOR_RED           0xFF0000FF
#define COLOR_YELLOW        0xFFFF00AA
#define COLOR_WHITE         0xFFFFFFAA
#define COLOR_BLUE          0x0000FFAA
#define COLOR_BROWN         0x993300AA
#define COLOR_ORANGE        0xFF9933AA
#define COLOR_CYAN          0x99FFFFAA
#define COLOR_PINK          0xFF66FFAA
#define COLOR_BLACK         0x2C2727AA
#define COLOR_LIGHTCYAN     0xAAFFCC33
#define COLOR_LEMON         0xDDDD2357
#define COLOR_AQUA          0x7CFC00AA
#define COLOR_WHITEYELLOW   0xFFE87DFF
#define COLOR_BLUEAQUA      0x7E60FFFF
#define COLOR_DARKBLUE      0x15005EFF
#define COLOR_ALIEN         0x90FF87FF
#define COLOR_GREY          0xAFAFAFAA
#define COLOR_GREEN         0x33AA33AA
#define COLOR_YELLOW        0xFFFF00AA
#define COLOR_LIGHTBLUE     0x00D0F6AA
#define COLOR_PURPLE        0xA600F6AA
#define COLOR_TUT           0xF6C861AA
#define COLOR_ROYAL         0x00C1F6AA

new pRank[MAX_PLAYERS];
new Text:Newbie;
new Text:BabyKilla;
new Text:Soldier;
new Text:Gangsta;
new Text:Underboss;
new Text:Boss;

public OnFilterScriptInit()
{
    Newbie = TextDrawCreate(500, 100, "Rank: Newbie");
    TextDrawAlignment(Newbie, 1);
    TextDrawFont(Newbie, 2);
    TextDrawLetterSize(Newbie, 0.400, 1.000);
    TextDrawColor(Newbie, COLOR_WHITE);
    TextDrawSetOutline(Newbie, 1);

    BabyKilla = TextDrawCreate(486, 100, "Rank: Baby Killa'");
    TextDrawAlignment(BabyKilla, 1);
    TextDrawFont(BabyKilla, 2);
    TextDrawLetterSize(BabyKilla, 0.400, 1.000);
    TextDrawColor(BabyKilla, COLOR_YELLOW);
    TextDrawSetOutline(BabyKilla, 1);

    Soldier = TextDrawCreate(500, 100, "Rank: Soldier");
    TextDrawAlignment(Soldier, 1);
    TextDrawFont(Soldier, 2);
    TextDrawLetterSize(Soldier, 0.400, 1.000);
    TextDrawColor(Soldier, COLOR_GREEN);
    TextDrawSetOutline(Soldier, 1);

    Gangsta = TextDrawCreate(500, 100, "Rank: Gangsta'");
    TextDrawAlignment(Gangsta, 1);
    TextDrawFont(Gangsta, 2);
    TextDrawLetterSize(Gangsta, 0.400, 1.000);
    TextDrawColor(Gangsta, COLOR_ROYAL);
    TextDrawSetOutline(Gangsta, 1);

    Underboss = TextDrawCreate(483, 100, "Rank: Underboss");
    TextDrawAlignment(Underboss, 1);
    TextDrawFont(Underboss, 2);
    TextDrawLetterSize(Underboss, 0.400, 1.000);
    TextDrawColor(Underboss, COLOR_PURPLE);
    TextDrawSetOutline(Underboss, 1);

    Boss = TextDrawCreate(490, 100, "Rank: Tha' Boss");
    TextDrawAlignment(Boss, 1);
    TextDrawFont(Boss, 2);
    TextDrawLetterSize(Boss, 0.400, 1.000);
    TextDrawColor(Boss, COLOR_TUT);
    TextDrawSetOutline(Boss, 1);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[24], str[28], ip[24];
    GetPlayerIp(playerid, ip, sizeof(ip));
    GetPlayerName(playerid, pname, sizeof(pname));
    format(str, sizeof(str), USERFILE, pname);
    pRank[playerid] = 0;
    if(!dini_Exists(str))
    {
        dini_Create(str);
        dini_IntSet(str, "RANK", 0);
        dini_Set(str, "IP", ip);
        pRank[playerid] = dini_Int(str, "RANK");
    }
    else
    {
        if(strcmp(ip, dini_Get(str, "IP"), true) == 0)
        {
            pRank[playerid] = dini_Int(str, "RANK");
        }
        else
        {
            new str2[68];
            format(str2, sizeof(str2), "You aren't the real %s! GTFO!", pname);
            SendClientMessage(playerid, COLOR_RED, str2);
            Kick(playerid);
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new pname[24], str[28];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(str, sizeof(str), USERFILE, pname);
    if(dini_Exists(str))
    {
        dini_IntSet(str, "RANK", pRank[playerid]);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Newbie);
    TextDrawShowForPlayer(playerid, BabyKilla);
    TextDrawShowForPlayer(playerid, Soldier);
    TextDrawShowForPlayer(playerid, Gangsta);
    TextDrawShowForPlayer(playerid, Underboss);
    TextDrawShowForPlayer(playerid, Boss);

    if(pRank[playerid] == 0)
    { // Newbie
        SetPlayerHealth(playerid, 50.0);
        GivePlayerWeapon(playerid, 22, 300);
        GivePlayerWeapon(playerid, 17, 500);
        TextDrawHideForPlayer(playerid, BabyKilla);
        TextDrawHideForPlayer(playerid, Soldier);
        TextDrawHideForPlayer(playerid, Gangsta);
        TextDrawHideForPlayer(playerid, Underboss);
        TextDrawHideForPlayer(playerid, Boss);
    }

    else if(pRank[playerid] == 1)
    { // Baby Killa
        SetPlayerHealth(playerid, 60.0);
        SetPlayerArmour(playerid, 15.0);
        GivePlayerWeapon(playerid, 23, 300);
        GivePlayerWeapon(playerid, 17, 500);
        GivePlayerWeapon(playerid, 5, 1);
        TextDrawHideForPlayer(playerid, Newbie);
        TextDrawHideForPlayer(playerid, Soldier);
        TextDrawHideForPlayer(playerid, Gangsta);
        TextDrawHideForPlayer(playerid, Underboss);
        TextDrawHideForPlayer(playerid, Boss);
    }

    else if(pRank[playerid] == 2)
    { // Soldier
        SetPlayerHealth(playerid, 70.0);
        SetPlayerArmour(playerid, 25.0);
        GivePlayerWeapon(playerid, 24, 150);
        GivePlayerWeapon(playerid, 5, 1);
        TextDrawHideForPlayer(playerid, BabyKilla);
        TextDrawHideForPlayer(playerid, Newbie);
        TextDrawHideForPlayer(playerid, Gangsta);
        TextDrawHideForPlayer(playerid, Underboss);
        TextDrawHideForPlayer(playerid, Boss);
    }

    else if(pRank[playerid] == 3)
    { // Gangsta
        SetPlayerHealth(playerid, 80.0);
        SetPlayerArmour(playerid, 50.0);
        GivePlayerWeapon(playerid, 29, 200);
        GivePlayerWeapon(playerid, 24, 150);
        TextDrawHideForPlayer(playerid, BabyKilla);
        TextDrawHideForPlayer(playerid, Soldier);
        TextDrawHideForPlayer(playerid, Newbie);
        TextDrawHideForPlayer(playerid, Underboss);
        TextDrawHideForPlayer(playerid, Boss);
    }

    else if(pRank[playerid] == 4)
    { // Underboss
        SetPlayerHealth(playerid, 90.0);
        SetPlayerArmour(playerid, 75.0);
        GivePlayerWeapon(playerid, 34, 100);
        GivePlayerWeapon(playerid, 24, 300);
        TextDrawHideForPlayer(playerid, BabyKilla);
        TextDrawHideForPlayer(playerid, Soldier);
        TextDrawHideForPlayer(playerid, Gangsta);
        TextDrawHideForPlayer(playerid, Newbie);
        TextDrawHideForPlayer(playerid, Boss);
    }

    else if(pRank[playerid] == 5)
    { // Tha' Boss
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        GivePlayerWeapon(playerid, 27, 100);
        GivePlayerWeapon(playerid, 24, 500);
        GivePlayerWeapon(playerid, 31, 500);
        TextDrawHideForPlayer(playerid, BabyKilla);
        TextDrawHideForPlayer(playerid, Soldier);
        TextDrawHideForPlayer(playerid, Gangsta);
        TextDrawHideForPlayer(playerid, Underboss);
        TextDrawHideForPlayer(playerid, Newbie);
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
    new string[256];
    if(GetPlayerScore(killerid) == 5) // Amount of required kills to get rank 1 *Baby Killa'*
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *Baby Killa'* by killing %d players", string, GetPlayerScore(killerid) );
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, 5000);
        pRank[playerid] = 1;
    }
    else if(GetPlayerScore(killerid) == 25) // Amount of required kills to get rank 2 *Soldier*
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *Soldier* by killing %d players", string, GetPlayerScore(killerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, 5000);
        pRank[playerid] = 2;
    }
    else if(GetPlayerScore(killerid) == 50) // Amount of required kills to get rank 3 *Gangsta'*
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *Gangsta'* by killing %d players", string, GetPlayerScore(killerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, 5000);
        pRank[playerid] = 3;
    }
    else if(GetPlayerScore(killerid) == 150) // Amount of required kills to get rank 4 *Underboss*
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *UnderBoss* by killing %d players", string, GetPlayerScore(killerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, 5000);
        pRank[playerid] = 4;
    }
    else if(GetPlayerScore(killerid) == 300) // Amount of required kills to get rank 5 *Tha' Boss*
    {
        GetPlayerName(killerid, string, sizeof(string) );
        format(string, sizeof(string), ">> %s advanced to rank *The Boss* by killing %d players", string, GetPlayerScore(killerid));
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        GivePlayerMoney(playerid, 5000);
        pRank[playerid] = 5;
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(ranks, 5, cmdtext); //all
    return 1;
}

dcmd_ranks(playerid, params[])
{
    #pragma unused params
    new string[24];
    format(string, sizeof(string), "You are rank %d", pRank[playerid]);
    SendClientMessage(playerid,COLOR_WHITE, ".........:::: Rank Info Centre ::::........");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 0 -  *Newbie*  (0 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 1 -  *Baby Killa'*  (5 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 2 -  *Soldier*  (25 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 3 -  *Gangsta'*  (50 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 4 -  *UnderBoss*  (150 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 5 -  *Tha' Boss*  (300 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, string);
    return 1;
}
The /ini file isnt saves and the textdraws dont show up. What should i do
Reply
#2

No offense or anything, but that's an ugly code. Here's how I would do it:
pawn Код:
new
    Text:_pRank[MAX_PLAYERS],
    iRank[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    _pRank[playerid] = TextDrawCreate(500, 100, " ");
    TextDrawAlignment(_pRank[playerid], 1);
    TextDrawFont(_pRank[playerid], 2);
    TextDrawLetterSize(_pRank[playerid], 0.400, 1.000);
    TextDrawColor(_pRank[playerid], COLOR_WHITE);
    TextDrawSetOutline(_pRank[playerid], 1);

    // Insert your load rank info
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerRankTag(playerid);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

dcmd_ranks(playerid, params[])
{
    #pragma unused params
    new string[24];
    format(string, sizeof(string), "You are rank %d", pRank[playerid]);
    SendClientMessage(playerid,COLOR_WHITE, ".........:::: Rank Info Centre ::::........");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 0 -  *Newbie*  (0 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 1 -  *Baby Killa'*  (5 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 2 -  *Soldier*  (25 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 3 -  *Gangsta'*  (50 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 4 -  *UnderBoss*  (150 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, "Rank 5 -  *Tha' Boss*  (300 kills required)");
    SendClientMessage(playerid,COLOR_WHITE, string);
    return 1;
}

stock SetPlayerRankTag(playerid)
{
    new
        iRankStr[25];

    switch(pRank[playerid])
    {
        case 0:
        {
            SetPlayerHealth(playerid, 50.0);
            GivePlayerWeapon(playerid, 22, 300);
            GivePlayerWeapon(playerid, 17, 500);
            iRankStr = "Rank: Newbie";
        }
        case 1:
        {
            SetPlayerHealth(playerid, 60.0);
            SetPlayerArmour(playerid, 15.0);
            GivePlayerWeapon(playerid, 23, 300);
            GivePlayerWeapon(playerid, 17, 500);
            GivePlayerWeapon(playerid, 5, 1);
            iRankStr = "Rank: Baby Killa'";
        }
        case 2:
        {
            SetPlayerHealth(playerid, 70.0);
            SetPlayerArmour(playerid, 25.0);
            GivePlayerWeapon(playerid, 24, 150);
            GivePlayerWeapon(playerid, 5, 1);
            iRankStr = "Rank: Soldier";
        }
        case 3:
        {
            SetPlayerHealth(playerid, 80.0);
            SetPlayerArmour(playerid, 50.0);
            GivePlayerWeapon(playerid, 29, 200);
            GivePlayerWeapon(playerid, 24, 150);
            iRankStr = "Rank: Gangsta'";
        }
        case 4:
        {
            SetPlayerHealth(playerid, 90.0);
            SetPlayerArmour(playerid, 75.0);
            GivePlayerWeapon(playerid, 34, 100);
            GivePlayerWeapon(playerid, 24, 300);
            iRankStr = "Rank: Underboss";
        }
        case 5:
        {
            SetPlayerHealth(playerid, 100);
            SetPlayerArmour(playerid, 100);
            GivePlayerWeapon(playerid, 27, 100);
            GivePlayerWeapon(playerid, 24, 500);
            GivePlayerWeapon(playerid, 31, 500);
            iRankStr = "Rank: Tha' Boss";
        }
    }
    TextDrawSetString(_pRank[playerid], iRankStr);
    TextDrawShowForPlayer(playerid, _pRank[playerid]);
    return 1;
}
Reply
#3

that doesnt help at all!!! BUMP - URGENT!
Reply
#4

/remove
Reply
#5

wth? I still need this! Someone.. cant u just mod my code so that it works?
Reply
#6

bump - is it really that hard to fix?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)