afk things -
Lixyde - 05.03.2019
I made so when i type /afk i cant move, i get unlimited health.
How can i make it so when i type afk i cant use commands like for teleport. I mean the command /back will be available but the goto commands will be not. If there is a way.
And how can i make when you type /back it gets you the health you had before you typed /afk.
For now i have this:
Код:
new isAFK[MAX_PLAYERS];
new oldhealth;
CMD:afk(playerid, params[])
{
if(isAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Вече сте AFK!");
SendClientMessage(playerid, 0xFAFAFAFF, "Вече сте AFK. За да се върнете напишете /back");
TogglePlayerControllable(playerid, 0);
GetPlayerHealth(playerid, oldhealth);
SetPlayerHealth(playerid, Float:0x7F800000);
isAFK[playerid] = 1;
return 1;
}
CMD:back(playerid, params[])
{
if(isAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Вие не сте AFK!");
SendClientMessage(playerid, 0xFAFAFAFF, "Вече не сте AFK.");
TogglePlayerControllable(playerid, 1);
SetPlayerHealth(playerid, oldhealth);
isAFK[playerid] = 1;
return 1;
}
Also i have tag mismatch on this:
Код:
GetPlayerHealth(playerid, oldhealth);
please help.
Re: afk things -
TheToretto - 05.03.2019
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(isAFK[playerid] && strcmp(cmdtext, "/back", true))
return SendClientMessage(playerid, -1, "You are afk");
return 1;
}
Could you try this? I did this on the phone and it is untested, by the way declare your oldhealth as a float to avoid the warning for tag mismatch, and make it an array, else any last player using /back will get the amount of health of another one, because the variable is global.
pawn Код:
new Float: oldhealth[MAX_PLAYERS];
Re: afk things -
Lixyde - 05.03.2019
After i removed my oldhealth and added yours. It got me 2 mismatch errors.
I dont know what to type in it.
1 mismatch error is on /afk command:
Код:
GetPlayerHealth(playerid, oldhealth);
2 mismatch error is on /back command:
Код:
SetPlayerHealth(playerid, oldhealth);
Re: afk things -
TheToretto - 05.03.2019
Basically add [playerid] to it...
Re: afk things -
Lixyde - 05.03.2019
It doesnt work. I wanted when you are in /afk you cant use commands, or normal people (i mean not admin) cant use /goto on you. You can only use /back when you are /afk.
I added what you gived to me. It doesnt work. I type command like /stats and the command work, but in the chat it says You are Afk.
Re: afk things -
TheToretto - 05.03.2019
My bad, you should return 0 instead, and switch to OnPlayerCommandReceived instead, try this:
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(isAFK[playerid] && strcmp(cmdtext, "/back", true))
return SendClientMessage(playerid, -1, "You are afk"), 0;
return 1;
}
Logically you will be able to run only the command /back
Re: afk things -
Lixyde - 05.03.2019
1. expression has no effect
Error code:
Код:
SendClientMessage(playerid, -1, "You are afk"), 0;
Re: afk things -
TheToretto - 05.03.2019
Quote:
Originally Posted by Lixyde
1. expression has no effect
Error code:
Код:
SendClientMessage(playerid, -1, "You are afk"), 0;
|
Add return before SendClientMessage
Re: afk things -
Lixyde - 06.03.2019
I got it. I didnt read it carefully.
EDIT: Man.. You are genius. Rep+ for that.
Re: afk things -
MafiaOink - 06.03.2019
Also change
Код:
isAFK[playerid] = 1;
to
Код:
isAFK[playerid] = 0;
In cmd:back.