Unreachable code :/
#6

Quote:
Originally Posted by ProfeQ
Посмотреть сообщение
Код:
CMD:slap(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, 0x708090FF, "You are not a admin!");
        
	new targetid, string[128];
	if(isnull(params))
	    return SendClientMessage(playerid, 0x708090FF, "Syntax: /slap [playerid]");
	    
     if(!IsPlayerConnected(targetid))
	 	return SendClientMessage(playerid, 0xFFFFFFF,"That player is not connected to the server!");
	 	
	SetPlayerVelocity(targetid, 0.5, 0.0, 0.0);
	format(string, sizeof(string), "%s has slapped %s", GetName(playerid), GetName(targetid));
	SendMessageToRAdmins(0xFF0000FF, string);
	return 1;
}
Very messed up in your code. Don't use sscanf to a single command argument. You use the specifier "s" to the number that corresponds to a string. Take a look at my code and remember what and how.
That's not going to work, you never assign a value to targetid! Replacing:
Код:
if(isnull(params))
	    return SendClientMessage(playerid, 0x708090FF, "Syntax: /slap [playerid]");
with

Код:
if(sscanf(params,"r",targetid))
	    return SendClientMessage(playerid, 0x708090FF, "Syntax: /slap [playerid]");
Is far better, than the command can use the playerid, or the name (and it works).
Reply


Messages In This Thread
Unreachable code :/ - by GreenIsGo - 29.06.2012, 16:17
Re: Unreachable code :/ - by Ironboy - 29.06.2012, 16:26
Re: Unreachable code :/ - by Calabresi - 29.06.2012, 16:28
Re: Unreachable code :/ - by ProfeQ - 29.06.2012, 16:29
AW: Unreachable code :/ - by GreenIsGo - 29.06.2012, 16:33
Re: Unreachable code :/ - by pyrodave - 29.06.2012, 16:34
Re: Unreachable code :/ - by ProfeQ - 29.06.2012, 16:35
AW: Unreachable code :/ - by GreenIsGo - 29.06.2012, 16:37
AW: Re: Unreachable code :/ - by GreenIsGo - 29.06.2012, 16:39
Re: Unreachable code :/ - by Calabresi - 29.06.2012, 17:43

Forum Jump:


Users browsing this thread: 3 Guest(s)