09.12.2017, 19:33
PHP Code:
if(strcmp(version, "0.3.7-R2"))
{
SendClientMessage(playerid, COLOR_ROUGE_CLAIR, "Please install the latest version of SA:MP.");
SetTimerEx("kickdisplayer", 1000, 0, "d", playerid);
}
if(strcmp(version, "0.3.7-R2"))
{
SendClientMessage(playerid, COLOR_ROUGE_CLAIR, "Please install the latest version of SA:MP.");
SetTimerEx("kickdisplayer", 1000, 0, "d", playerid);
}
new samp_version[16]; GetPlayerVersion(playerid, samp_version, sizeof(samp_version)); if(strcmp(samp_version, "0.3.7") != 0 || strcmp(samp_version, "0.3.7-R2") != 0)//if NOT one of these versions { //Message that the client is wrong version //Message where to download the new version //kick in 250ms }
waste of lines you could use PHP Code:
waste of lines and CPU usage, you could send directly the messages (your messages won't appear to the player because the second one will be called after delayed kick finish and that's not cool. I can do it on fewer lines like that: PHP Code:
thanks for your shit long code mate! P.S: we need quality/rapidity, not the longer |
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
new bool:versioncheck, versionstring[10],playername[26],messagestring[80];
public OnPlayerConnect(playerid) {
GetPlayerName(playerid, playername, sizeof(playername)),GetPlayerVersion(playerid, versionstring, sizeof(versionstring));
if(!strcmp(versionstring, "0.3.7-R2")) { SendClientMessage(playerid,-1," Valid Version.");}
else { if(IsPlayerNPC(playerid)) return 0;
if(versioncheck == false) { format(messagestring, sizeof(messagestring), " Server Has Kicked %s, Reason : OLD CLIENT VERSION %s ", playername,versionstring);
SendClientMessageToAll(-1,messagestring);
SetTimerEx("DelayedMessages",500,false,"d",playerid), SetTimerEx("DelayedKick",1000, false, "d", playerid); }
else { format(messagestring, sizeof(messagestring), ".: Server Says: %s, OLD CLIENT VERSION %s, PLEASE UPDATE! :.", playername,versionstring);
SetTimerEx("DelayedMessages",500,false,"d",playerid);}}
return 1; }
forward DelayedKick(playerid);
forward DelayedMessages(playerid);
public DelayedKick(playerid) {
SetPlayerWeather(playerid, 999), SetPlayerVirtualWorld(playerid, 999), SetPlayerInterior(playerid,999), Kick(playerid);
return 1; }
public DelayedMessages(playerid) {
SendClientMessage(playerid,-1,".: OUTDATED VERSION, UPDATE FROM: sa-mp.com/download.php :.");
SendClientMessage(playerid,-1,".: OR COPY DIRECT LINK FROM YOUR CHATLOG https://sampforum.blast.hk/files/testing...nstall.exe :.");
return 1; }
CMD:togversion(playerid,params[]) {
if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"Unauthorized CMD");
if(versioncheck == false) {
versioncheck = true, SendClientMessage(playerid,-1,".: VERSION OFF :."); }
else if(versioncheck == true) {
versioncheck = false, SendClientMessage(playerid,-1,".: VERSION ON :."); }
return 1; }
//by billz
#define FILTERSCRIPT
#include <a_samp>
#include <izcmd> //you can use zcmd
new bool:CheckPlayerVersionKick; //make a boolean for PlayerVersion
CMD:togversion(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
if(!CheckPlayerVersionKick)
{
SendClientMessage(playerid, -1, "You have enabled version check.");//if it's off, turn it on.
CheckPlayerVersionKick = true;
return 1;
}
else if (CheckPlayerVersionKick)
{
SendClientMessage(playerid, -1, "You have disabled version check.");// if it's on, turn it off.
CheckPlayerVersionKick = false;
return 1;
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
new version[16],name[MAX_PLAYER_NAME], string[64+MAX_PLAYER_NAME];
GetPlayerVersion(playerid, version, sizeof(version));
if(!strcmp(version, "0.3.7-R2"))
{
SendClientMessage(playerid, -1, "You have an outdated SA-MP version. Please update it to {00ff00}[0.3.7-R2]");
SendClientMessage(playerid, -1, "http://sa-mp.com/download.php");
if(CheckPlayerVersionKick)
{
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s was kicked for an outdated version of SA-MP.", name);
SendClientMessageToAll(-1, string);
}
SetTimerEx("IfPlayerHasOutdatedVersion", 250, false, "i", playerid);
}
return 1;
}
forward IfPlayerHasOutdatedVersion(playerid);
public IfPlayerHasOutdatedVersion(playerid)
{
if(CheckPlayerVersionKick)
{
Kick(playerid);
return 1;
}
return 1;
}
3-
PHP Code:
PHP Code:
|
I can do it on fewer lines like that:
PHP Code:
|
CMD:togversion(playerid)
{
if(!IsPlayerAdmin(playerid)) return 1;
versioncheck = !versioncheck;
return SendClientMessage(playerid,-1,versioncheck ? (".: VERSION ON :.") : (".: VERSION OFF :."));
}
wtf ? No it's not..
though its good for readability please note that pawn has only one data type...bool is just a tag it's not gonna make any change to performance.. I can short it furthermore... PHP Code:
though @op it doesn't fit for a release and is terribly coded...1 star keep trying... |