An annoying warning.
#1

So, i have this afk command and works find it adds the 3DText but when i type again afk it doesn't remove the 3DText. Once i tried with Delete3DTextLabel(label); but it failed now with this new version it gaves me tag mismatch
I searched on wiki but still didn't find a solution to fix it.

pawn Код:
CMD:afk(playerid, params[]){
    new mystring[70], Text3D:label;
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][pAfk] == -1){
        format(mystring, sizeof(mystring), "*{DDDDDD}%s {00FF00}is now away from keyboard!",pname);
        SendClientMessageToAll(COLOR_LIME, mystring);
        TogglePlayerControllable(playerid, 0);
        PlayerInfo[playerid][pAfk] = 1;
        label = Create3DTextLabel("I'm away from my keyboard!", 0x00FF00FF, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
    }else{
        format(mystring, sizeof(mystring), "*{DDDDDD}%s {88FF00}is now back to his keyboard!",pname);
        SendClientMessageToAll(0x88FF00FF, mystring);
        TogglePlayerControllable(playerid, 1);
        PlayerInfo[playerid][pAfk] = -1;
        DeletePlayer3DTextLabel(playerid, label); //warning 213:tag mismatch
    }
    return 1;
}
Reply
#2

It is happening because the variable which stores the 3D Text ID gets destroyed when the command finishes .


Just make label a global and array variable and use Delete3DTextLabel to destroy the 3D Text created by Create3DTextLabel :


pawn Код:
//Put in the top of your gamemode:

new Text3D:label[MAX_PLAYERS];


//And use this command:

CMD:afk(playerid, params[]){
    new mystring[70];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][pAfk] == -1){
        format(mystring, sizeof(mystring), "*{DDDDDD}%s {00FF00}is now away from keyboard!",pname);
        SendClientMessageToAll(COLOR_LIME, mystring);
        TogglePlayerControllable(playerid, 0);
        PlayerInfo[playerid][pAfk] = 1;
        label[playerid] = Create3DTextLabel("I'm away from my keyboard!", 0x00FF00FF, 30.0, 40.0, 50.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
    }else{
        format(mystring, sizeof(mystring), "*{DDDDDD}%s {88FF00}is now back to his keyboard!",pname);
        SendClientMessageToAll(0x88FF00FF, mystring);
        TogglePlayerControllable(playerid, 1);
        PlayerInfo[playerid][pAfk] = -1;
        Delete3DTextLabel(label[playerid]);
    }
    return 1;
}


I hope that i have helped .
Reply
#3

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)