#1

How can make that command to work with reason,because when I use that command,don't work so great...

HTML Code:
CMD:respect(playerid, params[])
{
	new Player, Reason[256]; new Str[2500];
	//--------------------------------------------------------------------------
	if(sscanf(params, "uS[256]", Player, Reason)) return
	SendUsage(playerid, "/Respect [ID/Name] [1/-1] [Reason]");
	//--------------------------------------------------------------------------
	else if(!IsPlayerConnected(Player)) return
	SendClientMessage(playerid, COLOR_ULTRARED, "{00FF40}Player not connected");
	//--------------------------------------------------------------------------
	else if(Player == playerid) return
	SendClientMessage(playerid, COLOR_ULTRARED, "{00FF40}You cannot give yourself respect!");
	//--------------------------------------------------------------------------
	else if((gettime() - rldtime[playerid]) < 180) return
	SendClientMessage(playerid, COLOR_ULTRARED, "{00FF40}Sorry, but you can give a point of respect only once in an 3 minutes!");
	//--------------------------------------------------------------------------
	else
	{
		//----------------------------------------------------------------------
		if(CosminInfo[playerid][Like] == 0)
		{
		    CosminInfo[Player][Like] += 1;
			format(Str, 2500, "{FFFF1A}You have recieved a positive respect point from %s with reason: %s",PlayerName(playerid), playerid, Reason);
			SendClientMessage(Player, COLOR_YELLOW, Str);
			format(Str, 2500, "{FFFF1A}You have given %s a positvive respect point with reason: %s", PlayerName(Player), playerid, Reason);
			SendClientMessage(playerid, COLOR_YELLOW, Str);
			rldtime[playerid] = gettime();
		}
		//----------------------------------------------------------------------
	    else if(CosminInfo[playerid][Dislike] == 0)
		{
  			CosminInfo[Player][Dislike] += 1;
			format(Str, 2500, "{FFFF1A}You have recieved a negative respect point from %s with reason: %s",PlayerName(playerid), playerid, Reason);
			SendClientMessage(Player, COLOR_YELLOW, Str);
			format(Str, 2500, "{FFFF1A}You have given %s a negative respect point with reason: %s", PlayerName(Player), playerid, Reason);
			SendClientMessage(playerid, COLOR_YELLOW, Str);
			rldtime[playerid] = gettime();
		}
		//----------------------------------------------------------------------
	}
	return 1;
}
Reply
#2

You have to be more precise here...
Can you define 'don't work so great' please?

Looking at your code... I have a few things I would like to point out.
Quote:

Reason[256]; new Str[2500];

Why would you locate a size of 2500? That's a lot of memory that will never be used.
Also the reason is way to big of size. I don't imagine a whole story being written into a reason, neither will it be possible to send a message within SendClientMessage that is over 144 characters long.

Quote:

if(CosminInfo[playerid][Like] == 0)

With this check it would only be possible for a player to be liked (or disliked) 1 time and never again.


Quote:

if(sscanf(params, "uS[256]", Player, Reason))

You are using sscanf to declare and check for two variables, although, if I look at your
Quote:

SendUsage(playerid, "/Respect [ID/Name] [1/-1] [Reason]");

I am assuming you want 3 parameters to be used.

Another thing...
format(Str, 2500, "{FFFF1A}You have recieved a positive respect point from %s with reason: %s",PlayerName(playerid), playerid, Reason);
These parameters are not adding up... You are declaring two parameters (First one with PlayerName and second one with playerid, there is no other one to be used for 'Reason'

You could also do (And should) instead of
Quote:

format(Str, 2500, "

do
Quote:

format(Str, sizeof(Str), "

Reply
#3

Quote:
Originally Posted by justinnater
View Post
You have to be more precise here...
Can you define 'don't work so great' please?

Looking at your code... I have a few things I would like to point out.

Why would you locate a size of 2500? That's a lot of memory that will never be used.
Also the reason is way to big of size. I don't imagine a whole story being written into a reason, neither will it be possible to send a message within SendClientMessage that is over 144 characters long.


With this check it would only be possible for a player to be liked (or disliked) 1 time and never again.



You are using sscanf to declare and check for two variables, although, if I look at your I am assuming you want 3 parameters to be used.

Another thing...
format(Str, 2500, "{FFFF1A}You have recieved a positive respect point from %s with reason: %s",PlayerName(playerid), playerid, Reason);
These parameters are not adding up... You are declaring two parameters (First one with PlayerName and second one with playerid, there is no other one to be used for 'Reason'

You could also do (And should) instead of
do
I try to make something exactly how did you say,but,the result was same. And yes,there are must three parameters:
HTML Code:
if(sscanf(params, "uS[256]", Player, Reason))
Also,if I give respect,just one work,exemple,I can't give negative respect,just postive.
Reply
#4

I addressed where the problems are comming from and how they should be handled.

What is it you have an issue with for fixing it?\


Edit;

Quote:
Originally Posted by SeeNN
View Post
HTML Code:
if(sscanf(params, "uS[256]", Player, Reason))
Also,if I give respect,just one work,exemple,I can't give negative respect,just postive.
Add another param in the sscanf.
Example:
Code:
if(sscanf(params, "uiS[256]", Player, Amount, Reason))
Make a checker on the amount (Whether it's positive or negative, along with the requirement of the amount that can be given) instead of checking how much Likes or Dislikes the player has.
Reply
#5

Quote:
Originally Posted by justinnater
View Post
I addressed where the problems are comming from and how they should be handled.

What is it you have an issue with for fixing it?\


Edit;




Add another param in the sscanf.
Example:
Code:
if(sscanf(params, "uiS[256]", Player, Amount, Reason))
Make a checker on the amount (Whether it's positive or negative, along with the requirement of the amount that can be given) instead of checking how much Likes or Dislikes the player has.
I will try,thank's.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)