Trying to add timer... -
Dokins - 05.02.2013
pawn Код:
SetTimer("DoLoginProcess", 3000,0);
pawn Код:
//TOPOFSCRIPT
forward DoLoginProcess();
Under OnPlayerConnect
pawn Код:
public DoLoginProcess
(){ new escape
[MAX_PLAYER_NAME
*2];
mysql_real_escape_string
(GetName
(playerid
), escape
);
format(query,
sizeof(query
),
"SELECT `id` FROM `accounts` WHERE `PlayerName` = '%s' LIMIT 1", escape
);
mysql_query
(query
);
mysql_store_result
();
if(mysql_num_rows
() > 0) { PlayerSQLID
[playerid
] = mysql_fetch_int
();
new string
[256],ip
[16], pip;
Tazed
[playerid
] = 0;
pip
= GetPlayerIp
(playerid, ip,
sizeof(ip
));
Time
[playerid
] = gettime();
BanTime
[playerid
] = MySQL_GetValue
(PlayerSQLID
[playerid
],
"BanTime",
"accounts");
if(BanTime
[playerid
] > Time
[playerid
]) { format(string,
sizeof(string
),
"You are still {FF0000}BANNED{FFFFFF} from Bone County Roleplay until {FF0000}%s", date
(BanTime
[playerid
]));
SendClientMessage
(playerid, COLOUR_WHITE, string
);
SendClientMessage
(playerid, COLOUR_REALRED,
"{FFFFFF}PLEASE DO {FF0000}NOT{FFFFFF} POST A {FF0000}BAN APPEAL {FFFFFF}as this is a Temporary Ban.");
SetTimerEx
("KickPlayer",
100,false,
"i",playerid
);
// Kicks player in 500ms } if(Time
[playerid
] > BanTime
[playerid
]) // Check when a player connects to see if they have a timestamp, and if they do, check if it exceeds gettime() { MySQL_SetInteger
(PlayerSQLID
[playerid
],
"BanTime",
0,
"accounts");
} if(IsPlayerBanned
(playerid
) == 1) { format(string,
sizeof(string
),
"Your IP:{FF0000} %s{FFFFFF} is {FF0000}BANNED{FFFFFF} from Bone County Roleplay.", pip
);
SendClientMessage
(playerid, COLOUR_WHITE, string
);
format(string,
sizeof(string
),
"PLEASE POST A {FF0000}BAN APPEAL{FFFFFF} ON http://bc-rp.net/forum/");
SendClientMessage
(playerid, COLOUR_WHITE, string
);
SetTimerEx
("KickPlayer",
100,false,
"i",playerid
);
// Kicks player in 500ms } if(BanTime
[playerid
] == 0 && IsPlayerBanned
(playerid
)== 0) { format(string,
sizeof(string
),
"Welcome to %s (SQLID %d)\n\nPlease enter your password below:", HOSTNAME, PlayerSQLID
[playerid
]);
ShowPlayerDialog
(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,
"Login Dialog", string,
"Login",
"Leave");
} } else { new string
[256];
format(string,
sizeof(string
),
"Welcome to %s\n\nPlease create an account by entering a password below:", HOSTNAME
);
ShowPlayerDialog
(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,
"Register Dialog", string,
"Register",
"Leave");
} mysql_free_result
();
}}
The reason I'm trying to delay it is that there appears to be a little lag before the player connects and if they're banned it kicks them after login sometimes. Therefore I'm trying to set a timer after the server has loaded to do checks. It says: DoLoginProcess is not implemented.
Re: Trying to add timer... -
Pangea - 05.02.2013
Quote:
Originally Posted by Dokins
There is nothing wrong with my code.
|
So, you're in no need of help and yet you post this in the Scripting
help section?
Re: Trying to add timer... -
Dokins - 05.02.2013
Forgive me. I meant that there is nothing wrong with the code contained in the Public. Do not presume, please.
Re: Trying to add timer... -
Pangea - 05.02.2013
You have one } too much at the end.
pawn Код:
public DoLoginProcess
(){ new escape
[MAX_PLAYER_NAME
*2];
mysql_real_escape_string
(GetName
(playerid
), escape
);
format(query,
sizeof(query
),
"SELECT `id` FROM `accounts` WHERE `PlayerName` = '%s' LIMIT 1", escape
);
mysql_query
(query
);
mysql_store_result
();
if(mysql_num_rows
() > 0) { PlayerSQLID
[playerid
] = mysql_fetch_int
();
new string
[256],ip
[16], pip;
Tazed
[playerid
] = 0;
pip
= GetPlayerIp
(playerid, ip,
sizeof(ip
));
Time
[playerid
] = gettime();
BanTime
[playerid
] = MySQL_GetValue
(PlayerSQLID
[playerid
],
"BanTime",
"accounts");
if(BanTime
[playerid
] > Time
[playerid
]) { format(string,
sizeof(string
),
"You are still {FF0000}BANNED{FFFFFF} from Bone County Roleplay until {FF0000}%s", date
(BanTime
[playerid
]));
SendClientMessage
(playerid, COLOUR_WHITE, string
);
SendClientMessage
(playerid, COLOUR_REALRED,
"{FFFFFF}PLEASE DO {FF0000}NOT{FFFFFF} POST A {FF0000}BAN APPEAL {FFFFFF}as this is a Temporary Ban.");
SetTimerEx
("KickPlayer",
100,false,
"i",playerid
);
// Kicks player in 500ms } if(Time
[playerid
] > BanTime
[playerid
]) // Check when a player connects to see if they have a timestamp, and if they do, check if it exceeds gettime() { MySQL_SetInteger
(PlayerSQLID
[playerid
],
"BanTime",
0,
"accounts");
} if(IsPlayerBanned
(playerid
) == 1) { format(string,
sizeof(string
),
"Your IP:{FF0000} %s{FFFFFF} is {FF0000}BANNED{FFFFFF} from Bone County Roleplay.", pip
);
SendClientMessage
(playerid, COLOUR_WHITE, string
);
format(string,
sizeof(string
),
"PLEASE POST A {FF0000}BAN APPEAL{FFFFFF} ON http://bc-rp.net/forum/");
SendClientMessage
(playerid, COLOUR_WHITE, string
);
SetTimerEx
("KickPlayer",
100,false,
"i",playerid
);
// Kicks player in 500ms } if(BanTime
[playerid
] == 0 && IsPlayerBanned
(playerid
)== 0) { format(string,
sizeof(string
),
"Welcome to %s (SQLID %d)\n\nPlease enter your password below:", HOSTNAME, PlayerSQLID
[playerid
]);
ShowPlayerDialog
(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,
"Login Dialog", string,
"Login",
"Leave");
} } else { new string
[256];
format(string,
sizeof(string
),
"Welcome to %s\n\nPlease create an account by entering a password below:", HOSTNAME
);
ShowPlayerDialog
(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,
"Register Dialog", string,
"Register",
"Leave");
} mysql_free_result
();
}
Re: Trying to add timer... -
Dokins - 05.02.2013
I used a brackets counter, I don't
Re: Trying to add timer... -
Pangea - 05.02.2013
Then you pasted an extra }, because in the public you gave us, it definitely had one closing bracket too much.
Re: Trying to add timer... -
Dokins - 05.02.2013
Yeah you're right, but I removed the one you did and it still comes with like 26 errors telling me that it's missing one
Re: Trying to add timer... -
Da_Noob - 05.02.2013
Maybe you can try SetTimerEx, if your timer is the problem.
pawn Код:
SetTimerEx("DoLoginProcess", 3000,0, "i", playerid);
Re: Trying to add timer... -
Dokins - 05.02.2013
It's not the timer. I've messed up brackets somewhere.