Problem :/ Help..
#1

I have problem with /bribe and /accept command for cops ... Bribe command works fine , but when i do /accept it relase ME from jail instead of person who offered me bribe ... i can not define other player in /accept command ...here's code


Код:
dcmd_bribe(playerid,params[])
{
	new string[128];
	new ID, amount;
    if(sscanf(params, "ui", ID, amount))
	{
	    SendClientMessage(playerid,COLOR_RED,"USAGE: /bribe (Player Name/ID) (Amount)");
	    return 1;
	}
	if(playerid == ID)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot bribe yourself!");
	    return 1;
	}
	if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
	}
	if(!IsPlayerConnected(ID))
	{
		format(string,sizeof(string),"The Player ID (%d) is not connected to the server. You cannot give bribe to them.",ID);
        SendClientMessage(playerid,COLOR_RED,string);
		return 1;
	}
	if(gTeam[ID] == CIVILIAN)
	{
	    SendClientMessage(playerid,COLOR_RED,"Only Police Officers can be bribed!");
	    return 1;
	}
	if(HasBribedRecently[playerid] >= 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"Please wait before attempting to bribe someone again.");
	    return 1;
	}
	if(GetPlayerMoney(playerid) < amount)
	{
	    SendClientMessage(playerid,COLOR_RED,"You do not have that amount of money!");
	    return 1;
	}
	if(amount > 20000 || amount < 5000)
	{
	    SendClientMessage(playerid,COLOR_RED,"Please enter ammount from 5000$ up to 20.000$");
	    return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) > 15)
	{
	    SendClientMessage(playerid,COLOR_RED,"That player is not close enough in order bribe him.");
	    return 1;
	}
	format(string,sizeof(string),"You have offered bribe to %s(%d).",PlayerName(ID),ID);
	SendClientMessage(playerid,COLOR_SERVER,string);
	format(string,sizeof(string),"You have recived $%d bribe from %s (%d).   /accept or   /decline.",amount,PlayerName(playerid),playerid);
	SendClientMessage(ID,COLOR_SERVER,string);
	HasOfferforBribe[ID] =1;
	HasBribedRecently[playerid] =30;
	return 1;
}


dcmd_accept(playerid,params[])
{
    #pragma unused params
	new string[128];
	new ID, amount;
	if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
	}
	if(!IsPlayerConnected(ID))
	{
		format(string,sizeof(string),"The Player ID (%d) is not connected to the server.",ID);
        SendClientMessage(playerid,COLOR_RED,string);
		return 1;
	}
	if(HasOfferforBribe[playerid] != 1)
	{
 		SendClientMessage(playerid,COLOR_RED,"You do not have any bribe offer to accept.");
 		return 1;
 	}
	if(GetDistanceBetweenPlayers(playerid,ID) > 15)
	{
	    SendClientMessage(playerid,COLOR_RED,"That player is not close enough in order to accept bribe.");
	    return 1;
	}
	SendClientMessage(ID,COLOR_ORANGE,"Your bribe has been accepted . You are free to go!");
	JailTime[ID] =0;
 	TotalJailTime[ID] =0;
 	Jailed[ID] = false;
	SetPlayerWantedLevel(ID, 0);
	SetPlayerInterior(ID, 0);
	SetPlayerPos(ID, 1546.0634,-1675.3385,13.5616);
	SetPlayerFacingAngle(ID, 13.5616);
	SetCameraBehindPlayer(ID);
 	GivePlayerMoney(ID, -amount);
 	format(string, sizeof(string), "%s (%d) has been released from jail.",PlayerName(ID),ID);
	SendClientMessageToAll(COLOR_SERVER,string);
 	SetPlayerHealth(ID, 100);
	return 1;
}
So problem is in that /accept command..
Thanks in advance
Reply
#2

you used sscanf to give the variable ID a value in the first command, then in the second command ID was given no value, if you want it to be the same in both commands define it at the top of your script under the includes. E.G:

#include <samp>

new ID;
Reply
#3

Nah , its not solution , i just tried , same effect , command /accept still do not define player who bribed me , it still relases me from jail :/

Anyone else ??

Giving +14569 rep for solveing this prob
Reply
#4

Conceptz knows what he's talking about.

You need to create a global variable for stuff like this (meaning at the top of the script):

Add these new things:

pawn Код:
// top of script

new id, amount;

// bottom of script

dcmd_bribe(playerid,params[])
{
    new string[128];
   
    if(sscanf(params, "ui", id, amount))
    {
        SendClientMessage(playerid,COLOR_RED,"USAGE: /bribe (Player Name/ID) (Amount)");
        return 1;
    }
    if(playerid == id)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot bribe yourself!");
        return 1;
    }
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        format(string,sizeof(string),"The Player ID (%d) is not connected to the server. You cannot give bribe to them.",ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(gTeam[id] == CIVILIAN)
    {
        SendClientMessage(playerid,COLOR_RED,"Only Police Officers can be bribed!");
        return 1;
    }
    if(HasBribedRecently[playerid] >= 1)
    {
        SendClientMessage(playerid,COLOR_RED,"Please wait before attempting to bribe someone again.");
        return 1;
    }
    if(GetPlayerMoney(playerid) < amount)
    {
        SendClientMessage(playerid,COLOR_RED,"You do not have that amount of money!");
        return 1;
    }
    if(amount > 20000 || amount < 5000)
    {
        SendClientMessage(playerid,COLOR_RED,"Please enter ammount from 5000$ up to 20.000$");
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,id) > 15)
    {
        SendClientMessage(playerid,COLOR_RED,"That player is not close enough in order bribe him.");
        return 1;
    }
    format(string,sizeof(string),"You have offered bribe to %s(%d).",PlayerName(id),id);
    SendClientMessage(playerid,COLOR_SERVER,string);
    format(string,sizeof(string),"You have recived $%d bribe from %s (%d).   /accept or   /decline.",amount,PlayerName(playerid),playerid);
    SendClientMessage(id,COLOR_SERVER,string);
    HasOfferforBribe[id] =1;
    HasBribedRecently[playerid] =30;
    return 1;
}


dcmd_accept(playerid,params[])
{
    #pragma unused params
    new string[128];

    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The Player ID (%d) is not connected to the server.",id);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(HasOfferforBribe[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You do not have any bribe offer to accept.");
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,id) > 15)
    {
        SendClientMessage(playerid,COLOR_RED,"That player is not close enough in order to accept bribe.");
        return 1;
    }
    SendClientMessage(id,COLOR_ORANGE,"Your bribe has been accepted . You are free to go!");
    JailTime[id] =0;
    TotalJailTime[id] =0;
    Jailed[id] = false;
    SetPlayerWantedLevel(id, 0);
    SetPlayerInterior(id, 0);
    SetPlayerPos(id, 1546.0634,-1675.3385,13.5616);
    SetPlayerFacingAngle(id, 13.5616);
    SetCameraBehindPlayer(id);
    GivePlayerMoney(id, -amount);
    format(string, sizeof(string), "%s (%d) has been released from jail.",PlayerName(id),id);
    SendClientMessageToAll(COLOR_SERVER,string);
    SetPlayerHealth(id, 100);
    return 1;
}
Reply
#5

Change
pawn Код:
HasOfferforBribe[ID] =1;
To

pawn Код:
HasOfferforBribe[ID] = playerid;
Then set HasOfferforBribe[ID] to -1 when the player has nobody to bribe.

Then change
pawn Код:
if(HasOfferforBribe[playerid] != 1)
To
pawn Код:
if(HasOfferforBribe[playerid] != -1)
And finally change
pawn Код:
new ID, amount;
To
pawn Код:
new ID = HasOfferforBribe[playerid], amount;
Reply
#6

Thank you , to both of you , works fine now


rep added
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)