GetTextdrawX?
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
pvars are you kidding me?
PVars are really useful, except that the SA-MP PVar limit per player is around 800. PVars do allow you to do a lot of things and are useful if you use them carefully, this could've been done with the regular variables to save on performance and not have a lot of pvars being used but who is going to have 300 textdraws anyways?

Here's some of the things you can do with PVars:

pawn Код:
YCMD:setplayervar(playerid, params[], help) {
    if(help) {
        SendClientMessage(playerid, X11_WHITE, "Sets a player PVar");
        return 1;
    }
    new playa, name[64], value[64],type;
    if(!sscanf(params, "k<playerLookup_acc>ds[64]s[64]", playa, type, name, value)) {
        if(!IsPlayerConnected(playa)) {
            SendClientMessage(playerid, X11_RED3, "User not found.");
            return 1;
        }
        switch(type) {
            case PLAYER_VARTYPE_INT: {
                SetPVarInt(playa, name, strval(value));
            }
            case PLAYER_VARTYPE_STRING: {
                SetPVarString(playa, name, value);
            }
            case PLAYER_VARTYPE_FLOAT: {
                SetPVarFloat(playa, name, floatstr(value));
            }
            default: {
                SendClientMessage(playerid, X11_RED3, "Invalid Var Type! The valid types are: 1(int), 2(string), 3(float)");
                return 1;
            }
        }
        SendClientMessage(playerid, COLOR_CUSTOMGOLD, "[Notice]: Done!");
    } else {
        SendClientMessage(playerid, X11_WHITE, "USAGE: /SetPlayerVar [playerid/name] [type] [name] [value]");
    }
    return 1;
}
YCMD:deleteplayervar(playerid, params[], help) {
    if(help) {
        SendClientMessage(playerid, X11_WHITE, "Deletes a players PVar");
        return 1;
    }
    new playa, name[64];
    if(!sscanf(params, "k<playerLookup_acc>s[64]", playa, name)) {
        if(!IsPlayerConnected(playa)) {
            SendClientMessage(playerid, X11_RED3, "User not found.");
            return 1;
        }
        new type = GetPVarType(playa, name);
        if(type == PLAYER_VARTYPE_NONE) {
            SendClientMessage(playerid, X11_RED3, "Failed: PVar not found");
            return 1;
        }
        DeletePVar(playa, name);
        SendClientMessage(playerid, COLOR_CUSTOMGOLD, "[Notice]: Done!");
    } else {
        SendClientMessage(playerid, X11_WHITE, "USAGE: /DeletePlayerVar [playerid/name] [name]");
    }
    return 1;
}
While someone on the forums claimed they were slower, they don't need to be initialized as the regular variables, resulting in more lines of code. While it's not smart enough to use them for something like this, they're actually useful if they're used wisely.
Anyways, let's keep on topic.
Reply


Messages In This Thread
GetTextdrawX? - by SeniorGamer - 04.11.2013, 01:34
Re: GetTextdrawX? - by Ada32 - 04.11.2013, 02:24
Re: GetTextdrawX? - by Pottus - 04.11.2013, 03:02
Re: GetTextdrawX? - by InglewoodRoleplay - 04.11.2013, 03:10
Re: GetTextdrawX? - by Pottus - 04.11.2013, 03:13
Re: GetTextdrawX? - by InglewoodRoleplay - 04.11.2013, 03:20
Re: GetTextdrawX? - by Pottus - 04.11.2013, 03:24

Forum Jump:


Users browsing this thread: 1 Guest(s)