SA-MP Forums Archive
Problem in CMDS on my GM +1Rep - 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: Problem in CMDS on my GM +1Rep (/showthread.php?tid=575292)



Problem in CMDS on my GM +1Rep - Charalambos26 - 25.05.2015

Hello,

so there is a problem in the most of my cmds on my GM,
There are cmds like /givebounty, and if you put the id of the player you want to put a bounty, it says you cannot set a bounty on yourself, but its even not my id..

Need help
Reward +1Rep


Re: Problem in CMDS on my GM +1Rep - Ghazal - 25.05.2015

Why do you create a lot of threads? Just post them all in one thread.
Show me the code of /givebounty.


Re: Problem in CMDS on my GM +1Rep - FplayerGR - 25.05.2015

Show code please.

Edit:I did not reload when the post I published.


Re: Problem in CMDS on my GM +1Rep - Charalambos26 - 25.05.2015

Код HTML:
#define FILTERSCRIPT
#include <a_samp>
#include <streamer>
#include <YSI\y_commands>
#include <sscanf2>

new personalbountys = 0;
new defaultbounty = 50000;


stock GetPlayersName(playerid)
{
	new name[MAX_PLAYER_NAME];
 	GetPlayerName(playerid,name,sizeof(name));
  	for(new i = 0; i < MAX_PLAYER_NAME; i++)
   	{
    	if(name[i] == '_') name[i] = ' ';
   	}
    return name;
}

stock ConvertPrice(price)
{
    new pricestring[32];
    new j = valstr(pricestring,price);
    while(j >= 4) { j -= 3; strins(pricestring,",",j); }
    strins(pricestring,"$",0);
    return pricestring;
}



public OnFilterScriptInit()
{

	return 1;

}

public OnFilterScriptExit()
{

	return 1;

}


public OnPlayerConnect(playerid)
{
	SetPVarInt(playerid, "BountyOnHead", 0);
	SetPVarInt(playerid, "BountyAmount", 0);
	SetPVarString(playerid, "BountySetBy", "No one");
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	new string[126];
	if(killerid != INVALID_PLAYER_ID)
	{
	    if(GetPVarInt(playerid, "BountyOnHead") == 1)
	    {
	        new bountyamount = GetPVarInt(playerid, "BountyAmount");
	        SetPVarInt(playerid, "BountyOnHead", 0);
			SetPVarInt(playerid, "BountyAmount", 0);
			SetPVarString(playerid, "BountySetBy", "No one");
	        format(string, sizeof(string), "Bounty Information:{FFFFFF} %s just killed %s for a bounty total of: %s", GetPlayersName(killerid), GetPlayersName(playerid), ConvertPrice(bountyamount));
	        SendClientMessageToAll(0xFF0000C8, string);
			GivePlayerMoney(killerid, bountyamount);
			SetPlayerColor(playerid, 0xFFFFFF00);
	    }
	}
	return 1;
}

public OnPlayerUpdate(playerid)
{
	new string[126];
	if(GetPVarInt(playerid, "BountyOnHead") == 0) {
	    if(GetPlayerWantedLevel(playerid) > 5)
	    {
	        SetPVarInt(playerid, "BountyOnHead", 1);
	        SetPVarInt(playerid, "BountyAmount", defaultbounty);
	        SetPVarString(playerid, "BountySetBy", "Law Enforcement");
	        SetPlayerColor(playerid, 0xFF0000C8);
	        SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} Your wanted level has reached Six (6), there fore you have now got a bounty on your head. Watch out!");
			format(string, sizeof(string), "Bounty Information:{FFFFFF} %s has been given an automatic bounty of %s, go collect your reward!", GetPlayersName(playerid), ConvertPrice(GetPVarInt(playerid, "BountyAmount")));
			SendClientMessageToAll(0xFF0000C8, string);
			return 1;
	    }
	}
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	new string[126];
	if(GetPVarInt(clickedplayerid, "BountyOnHead") == 1)
	{
	    new clickedname[MAX_PLAYER_NAME+1];
	    format(string, sizeof(string), "Bounty Amount: %s\nSet By: %s", ConvertPrice(GetPVarInt(clickedplayerid, "BountyAmount")), GetPVarString(clickedplayerid, "BountySetBy", clickedname, MAX_PLAYER_NAME+1));
	    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Bounty Information", string, "Okay", "");
	}
	return 1;
}

CMD:setdefaultbounty(playerid, params[])
{
	new string[126];
	if(IsPlayerAdmin(playerid))
	{
		new amount;
		if(sscanf(params, "d", amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information: /setdefaultbounty [amount]");

		if(amount < 0) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information: A default bounty can not go below $0.");
		defaultbounty = amount;
		format(string, sizeof(string), "Bounty Information:{FFFFFF} The default bounty amount is now %s.", ConvertPrice(amount));
		SendClientMessageToAll(0xFF0000C8, string);
	}
	return 1;
}

CMD:personalbountys(playerid, params[])
{
	if(IsPlayerAdmin(playerid))
	{
		if(personalbountys == 0)
		{
		    personalbountys = 1;
			SendClientMessageToAll(0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are now enabled.");
		}
		else if(personalbountys == 1)
		{
		    personalbountys = 0;
		    SendClientMessageToAll(0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are now disbaled.");
		}
	}
	return 1;
}

CMD:givebounty(playerid, params[])
{
    if(personalbountys == 0) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are currently disabled.");

	new target, amount, string[126];
	if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");

	if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} You do not have that much money to place that bounty.");

	if(target == playerid) return SendClientMessage(playerid, 0xFFFFFF00, "Bounty Information:{FFFFFF} You can't set a bounty on your self.");

	if(GetPVarInt(target, "BountyOnHead") == 1) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} That player already has a bounty on them.");

	if(IsPlayerConnected(target))
	{
	    format(string, sizeof(string), "Bounty Information:{FFFFFF} %s has just set a bounty on %s for the sum of %s!", GetPlayersName(playerid), GetPlayersName(target), ConvertPrice(amount));
	    SendClientMessageToAll(0xFF0000C8, string);

	    SetPVarInt(target, "BountyOnHead", 1);
	    SetPVarInt(target, "BountyAmount", amount);
	    SetPVarString(target, "BountySetBy", GetPlayersName(playerid));
	    GivePlayerMoney(playerid, -amount);
	    SetPlayerColor(target, 0x000000FF);
	    return 1;
	}
	else if(!IsPlayerConnected(target))
	{
		SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} That player isn't connected.");
	}
	return 1;
}



Re: Problem in CMDS on my GM +1Rep - FplayerGR - 25.05.2015

if your problem this
Код:
if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");

	if(target == playerid) return SendClientMessage(playerid, 0xFFFFFF00, "Bounty Information:{FFFFFF} You can't set a bounty on your self.");
use in sscanf 'rd' r = playerid / name.


Код:
if(sscanf(params, "rd", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");



Re: Problem in CMDS on my GM +1Rep - Charalambos26 - 25.05.2015

Quote:
Originally Posted by FplayerGR
Посмотреть сообщение
if your problem this
Код:
if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");

	if(target == playerid) return SendClientMessage(playerid, 0xFFFFFF00, "Bounty Information:{FFFFFF} You can't set a bounty on your self.");
use in sscanf 'rd' r = playerid / name.


Код:
if(sscanf(params, "rd", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");
still not working


Re: Problem in CMDS on my GM +1Rep - J0sh... - 25.05.2015

Quote:
Originally Posted by FplayerGR
Посмотреть сообщение
if your problem this
Код:
if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");

	if(target == playerid) return SendClientMessage(playerid, 0xFFFFFF00, "Bounty Information:{FFFFFF} You can't set a bounty on your self.");
use in sscanf 'rd' r = playerid / name.


Код:
if(sscanf(params, "rd", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");
No, that sscanf code IS correct.


Re: Problem in CMDS on my GM +1Rep - Charalambos26 - 25.05.2015

Quote:
Originally Posted by Jamester
Посмотреть сообщение
No, that sscanf code IS correct.
But my isn't working :/
Can you maybe send me all the code with your sscanf code IS edit?