Command help
#1

Hello, i want this command that it is useable only one time, so if player did use /abwesend, then he can't do it again until he used the another one

Код:
CMD:abwesend(playerid,params[])
{
	SendClientMessage(playerid, FARBE_GRAU, "Du bist nun abwesend! Gib '/anwesend' ein wenn du wieder da bist.");
	if TogglePlayerControllable(playerid,0);
	anwesendabwesend[playerid] = Create3DTextLabel("Abwesend",0xFF0000DE,30.0,40.0,50.0,40.0,0);
	Attach3DTextLabelToPlayer(anwesendabwesend[playerid], playerid, 0.0, 0.0, 0.7);
	new string3[70];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(string3, sizeof(string3), "%s ist nun abwesend.", name);
	SendClientMessageToAll(FARBE_BRAUN, string3);
	return 1;
}
CMD:anwesend(playerid,params[])
{
	SendClientMessage(playerid, FARBE_GRAU, "Du bist nun wieder anwesend!");
	TogglePlayerControllable(playerid,1);
	new string3[70];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(string3, sizeof(string3), "%s ist wieder anwesend!", name);
	SendClientMessageToAll(FARBE_BRAUN, string3);
	Delete3DTextLabel(Text3D:anwesendabwesend[playerid]);
	return 1;
}
Reply
#2

pawn Код:
CMD:abwesend(playerid,params[])
{
    if(GetPVarInt(playerid, "IstAbwesend") == 1) SendClientMessage(playerid, FARBE_GRAU, "Du bist bereits abwesend! Gib '/anwesend' ein wenn du zurьck bist.");
    SendClientMessage(playerid, FARBE_GRAU, "Du bist nun abwesend! Gib '/anwesend' ein wenn du wieder da bist.");
    anwesendabwesend[playerid] = Create3DTextLabel("Abwesend",0xFF0000DE,30.0,40.0,50.0,40.0,0);
    Attach3DTextLabelToPlayer(anwesendabwesend[playerid], playerid, 0.0, 0.0, 0.7);
    new string3[70];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string3, sizeof(string3), "%s ist nun abwesend.", name);
    SendClientMessageToAll(FARBE_BRAUN, string3);
    SetPVarInt(playerid, "IstAbwesend", 1);
    return 1;
}
CMD:anwesend(playerid,params[])
{
    if(!GetPVarInt(playerid, "IstAbwesend")) return SendClientMessage(playerid, FARBE_GRAU, "Du bist nicht abwesend! Gib '/abwesend' ein wenn du weg willst.");
    SendClientMessage(playerid, FARBE_GRAU, "Du bist nun wieder anwesend!");
    TogglePlayerControllable(playerid,1);
    new string3[70];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string3, sizeof(string3), "%s ist wieder anwesend!", name);
    SendClientMessageToAll(FARBE_BRAUN, string3);
    Delete3DTextLabel(Text3D:anwesendabwesend[playerid]);
    SetPVarInt(playerid, "IstAbwesend", 0);
    return 1;
}
Reply
#3

Thank you, but this only works for /anwesend

I can type /abwesend more times, can you help me there? i will give you +rep
Reply
#4

I already see what exora did possibly wrong. Here are the possible correct codes:

pawn Код:
CMD:abwesend(playerid,params[])
{
    if(GetPVarInt(playerid, "IstAbwesend") == 1) SendClientMessage(playerid, FARBE_GRAU, "Du bist bereits abwesend! Gib '/anwesend' ein wenn du zurьck bist.");
    SendClientMessage(playerid, FARBE_GRAU, "Du bist nun abwesend! Gib '/anwesend' ein wenn du wieder da bist.");
    anwesendabwesend[playerid] = Create3DTextLabel("Abwesend",0xFF0000DE,30.0,40.0,50.0,40.0,0);
    Attach3DTextLabelToPlayer(anwesendabwesend[playerid], playerid, 0.0, 0.0, 0.7);
    new string3[70];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string3, sizeof(string3), "%s ist nun abwesend.", name);
    SendClientMessageToAll(FARBE_BRAUN, string3);
    SetPVarInt(playerid, "IstAbwesend", 0);
    return 1;
}
CMD:anwesend(playerid,params[])
{
    if(!GetPVarInt(playerid, "IstAbwesend")) return SendClientMessage(playerid, FARBE_GRAU, "Du bist nicht abwesend! Gib '/abwesend' ein wenn du weg willst.");
    SendClientMessage(playerid, FARBE_GRAU, "Du bist nun wieder anwesend!");
    TogglePlayerControllable(playerid,1);
    new string3[70];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(string3, sizeof(string3), "%s ist wieder anwesend!", name);
    SendClientMessageToAll(FARBE_BRAUN, string3);
    Delete3DTextLabel(Text3D:anwesendabwesend[playerid]);
    SetPVarInt(playerid, "IstAbwesend", 1);
    return 1;
}
Reply
#5

Woopsie. Replace the first line in the "abwesend" command;

pawn Код:
if(GetPVarInt(playerid, "IstAbwesend") == 1) SendClientMessage(playerid, FARBE_GRAU, "Du bist bereits abwesend! Gib '/anwesend' ein wenn du zurьck bist.");
to
pawn Код:
if(GetPVarInt(playerid, "IstAbwesend") == 1) return SendClientMessage(playerid, FARBE_GRAU, "Du bist bereits abwesend! Gib '/anwesend' ein wenn du zurьck bist.");
Reply
#6

edit / wait
Reply
#7

Thanks exxora it works now, +rep

______________
At the above guy
This didn't work ^_^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)