SA-MP Forums Archive
Help Me Fixing This Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help Me Fixing This Bug (/showthread.php?tid=630154)



Help Me Fixing This Bug - Speaker - 10.03.2017

Hello Guys I Have Added A System That Admin Can Enable And Disable Headshoot So Here Is My Code

Код:
CMD:disable(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 4 || IsPlayerAdmin(playerid)) {
	    if(isnull(params)) {
			SendClientMessage(playerid,red,"USAGE: /disable [antiswear / namekick / antispam / ping / readcmds / readpms /caps / admincmdmsgs /connectmsgs / autologin / headshoot]");
		}
	    new string[128], file[256]; format(file,sizeof(file),"ladmin/config/Config.ini");
		if(strcmp(params,"antiswear",true) == 1) {
			ServerInfo[AntiSwear] = 0;
			dini_IntSet(file,"AntiSwear",0);
			format(string,sizeof(string),"Administrator %s has disabled antiswear", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"namekick",true) == 1) {
			ServerInfo[NameKick] = 0;
			dini_IntSet(file,"NameKick",0);
			format(string,sizeof(string),"Administrator %s has disabled namekick", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
	 	} else if(strcmp(params,"antispam",true) == 1)	{
			ServerInfo[AntiSpam] = 0;
			dini_IntSet(file,"AntiSpam",0);
			format(string,sizeof(string),"Administrator %s has disabled antispam", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"ping",true) == 1)	{
			ServerInfo[MaxPing] = 0;
			dini_IntSet(file,"MaxPing",0);
			format(string,sizeof(string),"Administrator %s has disabled ping kick", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"readcmds",true) == 1) {
			ServerInfo[ReadCmds] = 0;
			dini_IntSet(file,"ReadCMDs",0);
			format(string,sizeof(string),"Administrator %s has disabled reading commands", PlayerName2(playerid));
			MessageToAdmins(blue,string);
		} else if(strcmp(params,"readpms",true) == 1) {
			ServerInfo[ReadPMs] = 0;
			dini_IntSet(file,"ReadPMs",0);
			format(string,sizeof(string),"Administrator %s has disabled reading pms", PlayerName2(playerid));
			MessageToAdmins(blue,string);
  		} else if(strcmp(params,"caps",true) == 1)	{
			ServerInfo[NoCaps] = 1;
			dini_IntSet(file,"NoCaps",1);
			format(string,sizeof(string),"Administrator %s has prevented captial letters in chat", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"admincmdmsgs",true) == 1) {
			ServerInfo[AdminCmdMsg] = 0;
			dini_IntSet(file,"AdminCMDMessages",0);
			format(string,sizeof(string),"Administrator %s has disabled admin command messages", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"connectmsgs",true) == 1)	{
			ServerInfo[ConnectMessages] = 0;
			dini_IntSet(file,"ConnectMessages",0);
			format(string,sizeof(string),"Administrator %s has disabled connect & disconnect messages", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"autologin",true) == 1)	{
			ServerInfo[AutoLogin] = 0;
			dini_IntSet(file,"AutoLogin",0);
			format(string,sizeof(string),"Administrator %s has disabled auto login", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"headshoot",true) == 1)	{
			ServerInfo[HeadShoot] = 0;
			dini_IntSet(file,"HeadShoot",0);
			format(string,sizeof(string),"Administrator %s has disabled headshoot", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else {
			SendClientMessage(playerid,red,"USAGE: /disable [antiswear / namekick / antispam / ping / readcmds / readpms /caps / admincmdmsgs /connectmsgs / autologin / headshoot]");
		} return 1;
	} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}

CMD:enable(playerid,params[]) {
   if(PlayerInfo[playerid][Level] >= 4 || IsPlayerAdmin(playerid)) {
	    if(isnull(params)) {
		SendClientMessage(playerid,red,"USAGE: [/enable [antiswear / namekick / antispam / ping / readcmds / readpms /caps / admincmdmsgs /connectmsgs / autologin / headshoot]");
		}
	    new string[128], file[256]; format(file,sizeof(file),"ladmin/config/Config.ini");
		if(strcmp(params,"antiswear",true) == 0) {
			ServerInfo[AntiSwear] = 1;
			dini_IntSet(file,"AntiSwear",1);
			format(string,sizeof(string),"Administrator %s has enabled antiswear", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"namekick",true) == 0)	{
			ServerInfo[NameKick] = 1;
			dini_IntSet(file,"NameKick",1);
			format(string,sizeof(string),"Administrator %s has enabled namekick", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
 		} else if(strcmp(params,"antispam",true) == 0)	{
			ServerInfo[AntiSpam] = 1;
			dini_IntSet(file,"AntiSpam",1);
			format(string,sizeof(string),"Administrator %s has enabled antispam", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"ping",true) == 0)	{
			ServerInfo[MaxPing] = 800;
			dini_IntSet(file,"MaxPing",800);
			format(string,sizeof(string),"Administrator %s has enabled ping kick", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"readcmds",true) == 0)	{
			ServerInfo[ReadCmds] = 1;
			dini_IntSet(file,"ReadCMDs",1);
			format(string,sizeof(string),"Administrator %s has enabled reading commands", PlayerName2(playerid));
			MessageToAdmins(blue,string);
		} else if(strcmp(params,"readpms",true) == 0) {
			ServerInfo[ReadPMs] = 1;
			dini_IntSet(file,"ReadPMs",1);
			format(string,sizeof(string),"Administrator %s has enabled reading pms", PlayerName2(playerid));
			MessageToAdmins(blue,string);
		} else if(strcmp(params,"caps",true) == 0)	{
			ServerInfo[NoCaps] = 1;
			dini_IntSet(file,"NoCaps",1);
			format(string,sizeof(string),"Administrator %s has allowed captial letters in chat", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"admincmdmsgs",true) == 0)	{
			ServerInfo[AdminCmdMsg] = 1;
			dini_IntSet(file,"AdminCmdMessages",1);
			format(string,sizeof(string),"Administrator %s has enabled admin command messages", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"connectmsgs",true) == 0) {
			ServerInfo[ConnectMessages] = 1;
			dini_IntSet(file,"ConnectMessages",1);
			format(string,sizeof(string),"Administrator %s has enabled connect & disconnect messages", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"autologin",true) == 0) {
			ServerInfo[AutoLogin] = 1;
			dini_IntSet(file,"AutoLogin",1);
			format(string,sizeof(string),"Administrator %s has enabled auto login", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"headshoot",true) == 0) {
			ServerInfo[HeadShoot] = 1;
			dini_IntSet(file,"HeadShoot",1);
			format(string,sizeof(string),"Administrator %s has enabled headshoot", PlayerName2(playerid));
			MessageToAdmins(green,string);
  } else {
		SendClientMessage(playerid,red,"USAGE: /enable [antiswear / namekick / antispam / ping / readcmds / readpms /caps / admincmdmsgs /connectmsgs / autologin / headshoot]");
		} return 1;
	} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
But I Am Having A Problem With Disable Command When I Type /disable headshoot it says see in the picture
http://imgur.com/a/3wCkX
It says antiswear but it should say headshoot


Re: Help Me Fixing This Bug - coool - 10.03.2017

Try changing
Quote:

if(strcmp(params,"antiswear",true) == 1)

to
Quote:

if(strcmp(params,"antiswear",true) == 0)

and so all the others


Re: Help Me Fixing This Bug - oSAINTo - 10.03.2017

try this
Код:
CMD:disable(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 4 || IsPlayerAdmin(playerid)) {
	    if(isnull(params)) {
			SendClientMessage(playerid,red,"USAGE: /disable [antiswear / namekick / antispam / ping / readcmds / readpms /caps / admincmdmsgs /connectmsgs / autologin / headshoot]");
		}
	    new string[128], string2[128], file[256]; format(file,sizeof(file),"ladmin/config/Config.ini");
		if(strcmp(params,"antiswear",true) == 1) {
			ServerInfo[AntiSwear] = 0;
			dini_IntSet(file,"AntiSwear",0);
			format(string,sizeof(string),"Administrator %s has disabled antiswear", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"namekick",true) == 1) {
			ServerInfo[NameKick] = 0;
			dini_IntSet(file,"NameKick",0);
			format(string,sizeof(string),"Administrator %s has disabled namekick", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
	 	} else if(strcmp(params,"antispam",true) == 1)	{
			ServerInfo[AntiSpam] = 0;
			dini_IntSet(file,"AntiSpam",0);
			format(string,sizeof(string),"Administrator %s has disabled antispam", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"ping",true) == 1)	{
			ServerInfo[MaxPing] = 0;
			dini_IntSet(file,"MaxPing",0);
			format(string,sizeof(string),"Administrator %s has disabled ping kick", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"readcmds",true) == 1) {
			ServerInfo[ReadCmds] = 0;
			dini_IntSet(file,"ReadCMDs",0);
			format(string,sizeof(string),"Administrator %s has disabled reading commands", PlayerName2(playerid));
			MessageToAdmins(blue,string);
		} else if(strcmp(params,"readpms",true) == 1) {
			ServerInfo[ReadPMs] = 0;
			dini_IntSet(file,"ReadPMs",0);
			format(string,sizeof(string),"Administrator %s has disabled reading pms", PlayerName2(playerid));
			MessageToAdmins(blue,string);
  		} else if(strcmp(params,"caps",true) == 1)	{
			ServerInfo[NoCaps] = 1;
			dini_IntSet(file,"NoCaps",1);
			format(string,sizeof(string),"Administrator %s has prevented captial letters in chat", PlayerName2(playerid));
			SendClientMessageToAll(blue,string);
		} else if(strcmp(params,"admincmdmsgs",true) == 1) {
			ServerInfo[AdminCmdMsg] = 0;
			dini_IntSet(file,"AdminCMDMessages",0);
			format(string,sizeof(string),"Administrator %s has disabled admin command messages", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"connectmsgs",true) == 1)	{
			ServerInfo[ConnectMessages] = 0;
			dini_IntSet(file,"ConnectMessages",0);
			format(string,sizeof(string),"Administrator %s has disabled connect & disconnect messages", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"autologin",true) == 1)	{
			ServerInfo[AutoLogin] = 0;
			dini_IntSet(file,"AutoLogin",0);
			format(string,sizeof(string),"Administrator %s has disabled auto login", PlayerName2(playerid));
			MessageToAdmins(green,string);
		} else if(strcmp(params,"headshoot",true) == 1)	{
			ServerInfo[HeadShoot] = 0;
			dini_IntSet(file,"HeadShoot",0);
			format(string2,sizeof(string2),"Administrator %s has disabled headshoot", PlayerName2(playerid));
			MessageToAdmins(green,string2);
		} else {
			SendClientMessage(playerid,red,"USAGE: /disable [antiswear / namekick / antispam / ping / readcmds / readpms /caps / admincmdmsgs /connectmsgs / autologin / headshoot]");
		} return 1;
	} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}



Re: Help Me Fixing This Bug - Speaker - 10.03.2017

Quote:
Originally Posted by coool
Посмотреть сообщение
Try changing
to

and so all the others
Thanks It Worked Can U Help Me With Another Thing I Am Having Another Problem That When A Vip Use Command Like /dcar The Vehicle Get Spawned Near Him But When He Left The Vehicle It Do Not Get Destroyed After Some Time Can U Help me In Making It That Only VIP Vehicles That Got Spawned With command /dcar get destroyed after some time plzz help me

Here is my command
Код:
CMD:dcar(playerid,params[]) {
 if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][dRank] >= 1) {
		new Float:x,Float:y,Float:z;
		GetPlayerPos(playerid,x,y,z);
		CreateVehicle(411,x,y,z,100,0,0,-1);
		PutPlayerInVehicle(playerid,411,2);
		} else return SendClientMessage(playerid,red,"ERROR: You Need Atleast Donor Rank 1 To Use This Command");
 } else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");



Re: Help Me Fixing This Bug - oSAINTo - 10.03.2017

How long do you want it to take before the car's deleted?


Re: Help Me Fixing This Bug - Speaker - 10.03.2017

5 min and also want to show message to him that vehicle will get destroyed after 5 min


Re: Help Me Fixing This Bug - oSAINTo - 10.03.2017

Add this to the top of your script somewhere:
Код:
new DonatorCarTimer[MAX_PLAYERS];
Switch the command to this:
Код:
CMD:dcar(playerid,params[]) {
 if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][dRank] >= 1) {
			new Float:x,Float:y,Float:z;
			GetPlayerPos(playerid,x,y,z);
			CreateVehicle(411,x,y,z,100,0,0,-1);
			PutPlayerInVehicle(playerid,411,2);
			SetTimerEx("DonatorCar", 300000, 0, "i", playerid);
			SendClientMessage(playerid, red, "WARNING: The car will despawn in 5 minutes!");
		} else return SendClientMessage(playerid,red,"ERROR: You Need Atleast Donor Rank 1 To Use This Command");
 } else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
Add this anywhere in the script:
Код:
forward DonatorCar(playerid);
public DonatorCar(playerid)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    DestroyVehicle(vehicleid);
    KillTimer(DonatorCarTimer[playerid]);
}



Re: Help Me Fixing This Bug - Toroi - 10.03.2017

Quote:
Originally Posted by oSAINTo
Посмотреть сообщение
Add this to the top of your script somewhere:
Seeing your previous posts I notice you are in a defensive mood, so, before everything, sorry for being alive.

The code you provided is pretty useless as it will destroy the player's vehicle 300 seconds after he uses the command. He can use the car for only 300 seconds, which is not.. cool?

The second problem with this code is that, if you use the /dcar command, leave the car and get in other car, the car you joined will get deleted after 300 seconds, which is not good at all.

The better way to do this function is to assign the car id to a player variable and detroy the car under OnPlayerStateChange, that way you can delete the car when the player decides to leave it.


Re: Help Me Fixing This Bug - oSAINTo - 10.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Seeing your previous posts I notice you are in a defensive mood, so, before everything, sorry for being alive.

The code you provided is pretty useless as it will destroy the player's vehicle 300 seconds after he uses the command. He can use the car for only 300 seconds, which is not.. cool?

The second problem with this code is that, if you use the /dcar command, leave the car and get in other car, the car you joined will get deleted after 300 seconds, which is not good at all.

The better way to do this function is to assign the car id to a player variable and detroy the car under OnPlayerStateChange, that way you can delete the car when the player decides to leave it.
Defensive mood? Not quite sure what you mean by that, anyways.

He said he wanted the car to be destroyed after 5 minutes. 5 minutes is 300 seconds, so that's correct.
The second part you stated about assigning the car id probably would be better. Yet, I can't be asked to put more effort into someone who isn't willing to say thanks or give rep for helping them out. @OP


Re: Help Me Fixing This Bug - Toroi - 10.03.2017

Quote:
Originally Posted by oSAINTo
Посмотреть сообщение
or give rep for helping them out.
What's with this reputation thing? Does the sa-mp team give you money the more reputation you have? If so, fucking rep me, if not, why do you even bother? Is not helping the main thing here?

Quote:

if(vehicleid == 411)

That's the vehicle model, not the vehicle ID.

Quote:

It should only play it once. I'm assuming that OP wants to use /saveallstats before he restarts the server. So.

The reason you do a loop is because you want to go through all the items you choose, in this case, IDs. If you stop in the first loop, it'll only apply the SaveStats function to the ID 0.

I'm not trying to look smart, really, i'm just poiting out your mistakes, please forgive me!