commands error, (easy +rep)
#1

i have always had this problem with my commands, i figured ages ago that i would just naturally figure out what's wrong with it but i'm still left confused.

Basically;

Whatever command i use that calls a tmp doesn't call it properly.. if that makes sence

so say someones name was Jacob_William on the server. I want to slap him.

So i do /slap Jacob

This will slap a different user, maybe even myself. (might be Id 0). Also even if the name isnt on the server, it will still slap someone else.

But if i use /slap 5
5 being the user's ID#

Then that player will be slapped and if the player id isn't connected the command will stop.


How do i go about this?? D:
Reply
#2

try to get the latest sscanf2.
Reply
#3

im using strtok
Reply
#4

pawn Код:
player = ReturnUser(tmp);
if(IsPlayerConnected(player))
{
   // Do your actions on the player
}
Can't say more since I have no idea what exactly you're using.
Reply
#5

I will paste a command as an example

Код:
	if(strcmp(cmd, "/slap", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
   if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /slap [playerid/PartOfName]");
				return 1;
			}
			new playa;
			new Float:shealth;
			new Float:slx, Float:sly, Float:slz;
			playa = strval(tmp);
   			if (PlayerInfo[playerid][pAdmin] >=1)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
			            if(PlayerInfo[playa][pAdmin] > PlayerInfo[playerid][pAdmin])
				        {
							SendClientMessage(playerid, COLOR_LIGHTRED, "Don't try slap higher ranks !");
							SetPlayerHealth(playerid, 0);
							return 1;
				        }
				        gettime(hour, minute, second);
						getdate(year, month, day);
				        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						GetPlayerHealth(playa, shealth);
						SetPlayerHealth(playa, shealth-5);
						GetPlayerPos(playa, slx, sly, slz);
						SetPlayerPos(playa, slx, sly, slz+5);
						PlayerPlaySound(playa, 1130, slx, sly, slz+5);
						printf("AdmCmd: %s slapped %s",sendername,  giveplayer);
						format(string, sizeof(string), "AdmCmd: %s was slapped by %s",giveplayer ,sendername);
						ABroadCast(COLOR_LIGHTRED,string,1);
						format(string, sizeof(string),"-\n\n-[%s %i, %i] - [%i-0%i-0%i] %d %s Slapped %s", Months[month], day, year, hour, minute, second, PlayerInfo[playerid][pAdmin],sendername, giveplayer);
						AdminLog(string);
					}
				}
			}
		}
		return 1;
	}
Hope it gives you some insight
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)