[HELP] Include Messup - i'm sick of it -
RollTi - 26.04.2012
I'm really sick of it i'm very tired i cannot find the solution on the problem
when i try /afk it freeze me but when i try second /afk it still doesn't unfreeze me
TogglePlayerAFK - true (freeze) : false (unfreeze)
here is exactly what i did
pawn Код:
CMD:afk(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
switch(GetPlayerAFKToggle(playerid))
{
case 0:
{
TogglePlayerAFK(playerid, true);
format(string, 128, "%s(%d) are Away from his Keyboard!", name, playerid);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are away from your keyboard!");
}
case 1:
{
TogglePlayerAFK(playerid, false);
format(string, 128, "%s(%d) are Back from his Keyboard!", name, playerid);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are back from your keyboard!");
}
}
return 1;
}
even if i make it if statement it make nonsense it still the same
Include Code
pawn Код:
#if defined _roAFK_included
#endinput
#endif
#define _roAFK_included
#include <a_samp>
#include <YSI\y_hooks>
new AFKing[MAX_PLAYERS],
AFKTimer[MAX_PLAYERS];
forward OnPlayerAFK(playerid);
/*
native TogglePlayerAFK(playerid, toggle);
native GetPlayerAFK(playerid);
*/
#if defined _FILTERSCRIPT_
hook roAFK_OnFilterScriptInit()
{
print("Your filterscript is using RollTi's Afficient AFK v1.0");
}
#else
hook roAFK_OnGameModeInit()
{
print("Your gamemode is using RollTi's Afficient AFK v1.0");
}
#endif
stock TogglePlayerAFK(playerid, bool:toggle)
{
new Float:hp;
GetPlayerHealth(playerid, hp);
if(toggle == false)
{
TogglePlayerControllable(playerid, 1);
AFKing[playerid] = 1;
SetPlayerHealth(playerid, hp);
KillTimer(AFKTimer[playerid]);
}
else if(toggle == true)
{
SetPlayerHealth(playerid, 9999999.9);
TogglePlayerControllable(playerid, 0);
AFKing[playerid] = 0;
AFKTimer[playerid] = SetTimerEx("OnPlayerAFK", 300000, false, "d", playerid);
}
return 1;
}
stock GetPlayerAFKToggle(playerid)
{
return AFKing[playerid];
}
Re: [HELP] Include Messup - i'm sick of it -
RollTi - 26.04.2012
and hey how do i add a word Unknown in my location system?
Re: [HELP] Include Messup - i'm sick of it -
zSuYaNw - 26.04.2012
You need make public "OnPlayerAFK(playerid)"
Re: [HELP] Include Messup - i'm sick of it -
RollTi - 26.04.2012
i already made OnPlayerAFK
pawn Код:
public OnPlayerAFK(playerid)
{
return Kick(playerid);
}
Re: [HELP] Include Messup - i'm sick of it -
zSuYaNw - 26.04.2012
Try this:
pawn Код:
#include <a_samp>
#include <YSI\y_hooks>
#define GetPlayerAFKToggle(%0) \
AFKing[%0]
new bool:AFKing[MAX_PLAYERS char];
forward OnPlayerAFK(playerid);
/*
native TogglePlayerAFK(playerid, toggle);
native GetPlayerAFK(playerid);
*/
#if defined _FILTERSCRIPT_
hook roAFK_OnFilterScriptInit()
{
print("Your filterscript is using RollTi's Afficient AFK v1.0");
SetTimer("eOnPlayerAFK", 300000, true);
}
#else
hook roAFK_OnGameModeInit()
{
print("Your gamemode is using RollTi's Afficient AFK v1.0");
}
#endif
stock TogglePlayerAFK(playerid, bool:toggle)
{
static Float:hp; GetPlayerHealth(playerid, hp);
if(!toggle)
{
TogglePlayerControllable(playerid, true);
SetPlayerHealth(playerid, hp);
KillTimer(AFKTimer[playerid]);
AFKing{playerid} = true;
}
if(toggle == true)
{
SetPlayerHealth(playerid, 9999999.9);
TogglePlayerControllable(playerid, 0);
AFKing{playerid} = true;
}
return 1;
}
eOnPlayerAfk(); public eOnPlayerAfk()
{
for(new i, e = GetMaxPlayers(); i != e; ++i){
if(IsPlayerConnected(i)) {
if(AFKing{i}){
CallLocalFunction("OnPlayerAFK", "i", i);
}
}
}
return 1;
}
Re: [HELP] Include Messup - i'm sick of it -
Ballu Miaa - 26.04.2012
The code seems fine to me atm. Let me check it clearly and completely.
Re: [HELP] Include Messup - i'm sick of it -
Ballu Miaa - 26.04.2012
pawn Код:
// Had this AFKSystem.inc in my directories. Check it if you can use it.
////////////////////////////////////////////////////////////////////////////////
//
// Lach's Multi AFK System v1.0 //
// by Antonio [G-RP] //
//
////////////////////////////////////////////////////////////////////////////////
//
// FEEL FREE TO EDIT THIS FILTERSCRIPT - BUT LEAVE THE CREDITS IN IT!
//
#include <a_samp>
#define MAX_AFKTIME 6 // In Minutes
forward StartAFK(playerid);
forward StopAFK(playerid);
forward Check();
new Float:Pos[MAX_PLAYERS][3];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Multi AFK System v1.0 by Antonio[G-RP]");
print("--------------------------------------\n");
SetTimer("Check", 1000, 1);
return 1;
}
public OnFilterScriptExit()
{
for(new i=0; i<MAX_PLAYERS; i++) {
StopAFK(i);
}
return 1;
}
public Check()
{
for(new i=0; i<MAX_PLAYERS; i++) {
if(!IsPlayerConnected(i)) continue;
new Float:x, Float:y, Float:z;
GetPlayerPos(i, x, y, z);
if(!GetPVarInt(i,"TabbedOut"))
{
if((GetTickCount() - GetPVarInt(i, "LastUpdate")) >= 1000) {
SetPVarInt(i, "TabbedOut", 1);
CallLocalFunction("StartAFK", "i", i);
}
if(x != 0) {
if(Pos[i][0] == x && Pos[i][1] == y && Pos[i][2] == z) {
SetPVarInt(i, "AFKTime", GetPVarInt(i, "AFKTime") + 1);
}
}
if(!(Pos[i][0] == x && Pos[i][1] == y && Pos[i][2] == z)) {
CallLocalFunction("StopAFK", "i", i);
}
}
if(GetPVarInt(i, "TabbedOut"))
{
SetPVarInt(i, "AFKTime", GetPVarInt(i, "AFKTime") + 1);
}
if(GetPVarInt(i, "AFKTime") == 300) {
CallLocalFunction("StartAFK", "i", i);
}
if(GetPVarInt(i, "AFKTime") >= MAX_AFKTIME*60) {
printf("Player AFK time %d", GetPVarInt(i, "AFKTime"));
new string[70], name[24];
GetPlayerName(i, name, 24);
format(string, sizeof(string), "%s was kicked by system for being AFK for %d minute(s).", name, MAX_AFKTIME);
SendClientMessageToAll(0xFFFFFFFF, string);
Kick(i);
}
GetPlayerPos(i, Pos[i][0], Pos[i][1], Pos[i][2]);
}
return 1;
}
public OnPlayerConnect(playerid)
{
for(new i=0; i<3; i++) {
Pos[playerid][i] = 0;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DeletePVar(playerid, "TabbedOut");
DeletePVar(playerid, "LastUpdate");
return 1;
}
public OnPlayerUpdate(playerid)
{
SetPVarInt(playerid, "LastUpdate", GetTickCount());
if(GetPVarInt(playerid, "TabbedOut")) {
SetPVarInt(playerid, "TabbedOut", 0);
CallLocalFunction("StopAFK", "i", playerid);
}
return 1;
}
public StartAFK(playerid)
{
if(GetPVarInt(playerid, "AFKText")) Delete3DTextLabel(Text3D:GetPVarInt(playerid, "AFKText"));
SetPVarInt(playerid, "AFKText", _:Create3DTextLabel("Player is AFK", 0xFF0000FF, 0.0, 0.0, 0.0, 25.0, GetPlayerVirtualWorld(playerid), 1));
Attach3DTextLabelToPlayer(Text3D:GetPVarInt(playerid, "AFKText"), playerid, 0.0, 0.0, 0.3);
SetPlayerColor(playerid, 0xFF0000FF);
return 1;
}
public StopAFK(playerid)
{
if(GetPVarInt(playerid, "AFKText")) Delete3DTextLabel(Text3D:GetPVarInt(playerid, "AFKText"));
if(GetPVarInt(playerid, "AFKTime")) DeletePVar(playerid, "AFKTime");
SetPlayerColor(playerid, 0xFFFFFFFF);
return 1;
}
Respuesta: [HELP] Include Messup - i'm sick of it -
Marricio - 26.04.2012
pawn Код:
stock TogglePlayerAFK(playerid, bool:toggle)
{
static Float:hp; GetPlayerHealth(playerid, hp);
if(!toggle)
{
TogglePlayerControllable(playerid, true);
SetPlayerHealth(playerid, hp);
KillTimer(AFKTimer[playerid]);
AFKing{playerid} = true;
}
if(toggle == true)
{
SetPlayerHealth(playerid, 9999999.9);
TogglePlayerControllable(playerid, 0);
AFKing{playerid} = true;
}
return 1;
}
to this
pawn Код:
stock TogglePlayerAFK(playerid, bool:toggle)
{
static Float:hp; GetPlayerHealth(playerid, hp);
if(!toggle)
{
TogglePlayerControllable(playerid, 1);
SetPlayerHealth(playerid, hp);
KillTimer(AFKTimer[playerid]);
AFKing{playerid} = false;
}
if(toggle == true)
{
SetPlayerHealth(playerid, 9999999.9);
TogglePlayerControllable(playerid, 0);
AFKing{playerid} = true;
}
return 1;
}
Also fixed a mistake that you'd have a problem with it later..
Re: [HELP] Include Messup - i'm sick of it -
RollTi - 26.04.2012
Fixed!
Thanks to all rep+ both of you
except Ballu, i cannot give Rep to ballu anymore i just give him about few minutes ago
Respuesta: Re: [HELP] Include Messup - i'm sick of it -
Marricio - 26.04.2012
Quote:
Originally Posted by RollTi
What happen to GetPlayerAFKToggle?
|
pawn Код:
TogglePlayerControllable( playerid, 0 ); // freezes the player
TogglePlayerControllable( playerid, 1 ); // unfreezes the player
You can use it as bool thought.