ID 0 problem
#1

Well, I'm working on a new script, and I'm using PVars for the first time.

I've made the following commands so far, and I'm trying to figure out why it won't work.

When a player uses ID 0, it does this:
[quote]
PlayerA(0) has raped PlayerA(1)
PlayerA(0) has been infected with STDs.
[quote]
when a player uses ID 1, it does this:
[quote]
PlayerB(1) has raped PlayerA(0)
PlayerA(0) has been infected with STDs.
[quote]
The ID's are right, the names aren't.
IT is only with the ID of "0."
Also, the first rape, when ID 0 does the rape, no one gets the STD. I can't figure this out. Help?
(Note: IT is the same thing with the command below it "/fondle")
Код:
command(rape, playerid, params[])
{
	new pname[24]; new opname[24]; new ID; GetPlayerName(playerid, pname, 24); GetPlayerName(ID, opname, 24); new string[200];
	if(gTeam[playerid] == Team_Cop || gTeam[playerid] == Team_Army || gTeam[playerid] == Team_FBI)
	{
		return SendClientMessage(playerid, COLOR_ERROR, "Cops/Army cannot rape people.");
	}
	if(gTeam[playerid] == Team_Terror || gTeam[playerid] == Team_Rape || gTeam[playerid] == Team_PrvtMed || gTeam[playerid] == Team_Steal)
	{
		if(GetPVarInt(playerid, "RapeRecently") == 1)
		{
			return SendClientMessage(playerid, COLOR_ERROR, "Command used recently. Please wait.");
		}
		if(GetPVarInt(playerid, "Spawned") == 0)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You must be alive to use that command.");
		}
		if(GetPVarInt(playerid, "Cuffed") == 1)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You are cuffed. You cannot use this command.");
		}
		if(GetPVarInt(playerid, "Jailed") == 1)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You are in jail. You cannot use this command.");
		}
		if(IsPlayerInAnyVehicle(playerid))
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in a vehicle.");
		}
		if(sscanf(params, "i", ID))
		{
			return SendClientMessage(playerid, COLOR_RED, "Usage: /rape (ID)");
		}
		if(ID == playerid)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape yourself.");
		}
		if(!IsPlayerConnected(ID))
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "Invalid Player ID.");
		}
		if(GetPVarInt(ID, "Jailed") == 1)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape a prisoner.");
		}
		if(GetPVarInt(ID, "Cuffed") == 1)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape that player. He/She is cuffed.");
		}
		if(IsPlayerInAnyVehicle(ID))
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "You cannot rape a player in a vehicle.");
		}
		if(GetDistanceBetweenPlayers(playerid, ID) > 4)
		{
		    return SendClientMessage(playerid, COLOR_ERROR, "Your dick is not big enough! Get closer!");
		}
		if(GetPVarInt(ID, "HasCondom") == 1)
		{
  			SendClientMessage(playerid, COLOR_ERROR, "That player had a condom. You failed to rape them.");
		    SendClientMessage(ID, COLOR_ERROR, "Your condom has protected you from a rape. You have lost your condom.");
		    SetPVarInt(ID, "HasCondom", 0);
			IncreaseWantedLevel(playerid, 1);
		}
		format(string, sizeof(string), "**RAPE COMPLETE**");
		SendClientMessage(playerid, COLOR_GREY, string);
		format(string, sizeof(string), "You have raped %s(%d).", opname, ID);
		SendClientMessage(playerid, COLOR_GREEN, string);
		if(gTeam[playerid] == Team_Rape)
		{
		    format(string, sizeof(string), "%s(%d) has been infected with STDs.", opname, ID);
		    SendClientMessageToAll(COLOR_RED, string);
		    IRC_Say(gGroupID, IRC_CHANNEL, string);
		    SetPVarInt(ID, "HasSTDs", 1);
		}
		format(string, sizeof(string), "**RAPE VICTIM**");
		SendClientMessage(ID, COLOR_GREY, string);
		format(string, sizeof(string), "You have been raped by %s(%d). You might have STDs.", pname, playerid);
		SendClientMessage(ID, COLOR_GREEN, string);
		format(string, sizeof(string), "%s(%d) has raped %s(%d)", pname, playerid, opname, ID);
		SendClientMessageToAll(COLOR_LIGHTBLUE, string);
		IRC_Say(gGroupID, IRC_CHANNEL, string);
		SetPVarInt(playerid, "RapeRecently", 1);
		SetTimer("RapeAgain", 1000*6*2, 0);
		return 1;
	}
	return 1;
}

command(fondle, playerid, params[])
{
	new ID; new pname[24]; new opname[24]; new string[200]; GetPlayerName(playerid, pname, 24); GetPlayerName(ID, opname, 24);
	if(gTeam[playerid] == Team_Cop || gTeam[playerid] == Team_Army || gTeam[playerid] == Team_FBI)
	{
	    SendClientMessage(playerid, COLOR_ERROR, "Cops/Army cannot fondle other people.");
		return 1;
	}
	if(gTeam[playerid] != Team_Rape)
	{
	    return 1;
	}
	if(GetPVarInt(playerid, "Spawned") == 0)
	{
		return SendClientMessage(playerid, COLOR_ERROR, "You must be spawned and alive to use this command.");
	}
	if(GetPVarInt(playerid, "Cuffed") == 1)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "You are cuffed. You cannot use this command.");
	}
	if(GetPVarInt(playerid, "Jailed") == 1)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "You cannot fondle someone. You are in jail.");
	}
	if(IsPlayerInAnyVehicle(playerid))
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command while in a vehicle.");
	}
	if(sscanf(params, "i", ID))
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "Usage: /fondle (ID)");
	}
	if(ID == playerid)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "You cannot fondle yourself.");
	}
	if(!IsPlayerConnected(ID))
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID.");
	}
	if(IsPlayerInAnyVehicle(ID))
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "You cannot fondle someone in a vehicle.");
	}
	if(GetDistanceBetweenPlayers(playerid, ID) > 5)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "That player is too far away to fondle.");
	}
	if(GetPVarInt(ID, "Cuffed") == 1)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "That player is cuffed, you cannot fondle him.");
	}
	if(GetPVarInt(ID, "Jailed") == 1)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "That player is in jail, you cannot fondle him.");
	}
	if(GetPVarInt(playerid, "FondleRecent") == 1)
	{
	    return SendClientMessage(playerid, COLOR_ERROR, "Please wait before using this command again.");
	}
	format(string, 200, "%s(%d) has fondled %s(%d)!", pname, playerid, opname, ID);
	SendClientMessageToAll(COLOR_LIGHTBLUE, string);
	IRC_Say(gGroupID, IRC_CHANNEL, string);
	format(string, 200, "**FONDLE COMPLETE**");
	SendClientMessage(playerid, COLOR_GREY, string);
	format(string, 200, "You have fondled %s(%d)", opname, ID);
	SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	format(string, 200, "%s(%d) has fondled you.", pname, playerid);
	SendClientMessage(ID, COLOR_LIGHTBLUE, string);
	IncreaseWantedLevel(playerid, 2);
	IncreaseScore(playerid, 1);
	SetPVarInt(playerid, "FondleRecent", 1);
	SetTimer("ResetFondle", 1000*60*3, 0);
	return 1;
}
I know some of it is nubby, just try to fix my problem, not point out what's wrong with the code please. It's ZCMD, as if you couldn't tell that.

Again, this is only for ID 0.
Reply
#2

replace:
pawn Код:
if(sscanf(params, "i", ID))
with
pawn Код:
if(sscanf(params, "u", ID))
Should work now.

Information with parameters:


sscanf2 has more than that, don't you worry
Reply
#3

Oh, thanks. I've always used "i" because an ID is an integer, but I forgot that 0 isn't O.O

Thanks!


EDIT

It is still not fixed D:

I'm ID 0.
I type /rape 1
(ID 1 is a valid ID.)
It says that I raped myself.


ID 1 types in /rape 0
It says they rape me.

...
Reply
#4

pawn Код:
new pname[24]; new opname[24]; new ID; GetPlayerName(playerid, pname, 24); GetPlayerName(ID, opname, 24); new string[200];
you understand now?

if not, keep reading.

new ID; is equivalent to new ID = 0;, so remove the opname get, and put it after the sscanf, (after you have made checks for if the id is invalid...etc)
Reply
#5

Well, now it's fixed ))))

Another issue has risen. I can't figure out what's wrong.
The SetGVarInt(); isn't working. I've tried with "new robbed;" and it worked fine. SetGVarInt(); just isn't working.
Code
Код:
		if(listitem == 5)
		{
			if(gTeam[playerid] == Team_Cop || gTeam[playerid] == Team_FBI || gTeam[playerid] == Team_Army)
			{
			    SendClientMessage(playerid, COLOR_ERROR, "You cannot attempt robbery.");
			    return 1;
			}
			if(getCheckpointType(playerid) != CP_StoreOne)
			{
			    SendClientMessage(playerid, COLOR_ERROR, "You must be in the 69 Cent store checkpoint to attempt robbery.");
			    return 1;
			}
			if(GetGVarInt("SixNineRobbed") == 1337)
			{
			  	SendClientMessage(playerid, COLOR_ERROR, "The 69 Cent store has been robbed recently.");
			    return 1;
			}
			new crand = random(100);
			if(crand > 10)
			{
				new mrand = random(100000);
				format(string, sizeof(string), "[ROBBERY]%s(%d) has robbed $%d from the 69 Cent Store in Los Santos (Train Station)", pname, playerid, mrand);
				GivePlayerMoney(playerid, mrand);
				SendClientMessageToAll(COLOR_LIGHTBLUE, string); IRC_Say(gGroupID, IRC_CHANNEL, string);
				SetGVarInt("SixNineRobbed", 1337);
				SetTimer("SixNineStoreRobAgain", 1000*60*5, 0);
				IncreaseWantedLevel(playerid, 2);
				IncreaseScore(playerid, 1);
				format(string, sizeof(string), "[ROBBERY]%s(%d) has robbed the 69 Cent Store. Go arrest him now.", pname, playerid);
				SendCopMessage(string);
				return 1;
			}
			else
			{
				format(string, sizeof(string), "%s(%d) has failed a robbery at the 69 Cent Store in Los Santos (Train Station)", pname, playerid);
				SendClientMessageToAll(COLOR_LIGHTBLUE, string); IRC_Say(gGroupID, IRC_CHANNEL, string);
			}
		    return 1;
		}
		return 1;
	}
Any ideas?
Reply
#6

are you minusing it in a timer..?

pawn Код:
if(GetGVarInt("SixNineRobbed") > 0)
Reply
#7

No, I've checked. IT doesn't even set. I've tested in commands to set it myself, and it doesn't, not even calling the timer, or the reset function.
Reply
#8

ask in the gvar topic. S:

maybe u need to use a gvar id?

pawn Код:
native SetGVarInt(const name[], value, id = 0);
native GetGVarInt(const name[], id = 0);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)