Weapon name(Duel command)
#1

How to use this is command for weapon name and not weapon id?

Example: /duel [playerid] [weapon id or name]

Код:
CMD:duel(playerid, params[])
{
	if ( sscanf( params, "ud", params[ 0 ], params[ 1 ] ) )
	    return SendUsage(playerid, "/duel [playerid] [weapon id]");
	







	if(g_HasInvitedToDuel[playerid] == 1)
		return SendError(playerid, "You already invited someone to a duel! ~n~Type ~b~~h~/duel~w~ to reset your invite");

	new
		tString[256]
	;

	if (!IsPlayerConnected( params[ 0 ] ))
	    return SendError(playerid, "Player is not connected.");

 	if(	g_HasInvitedToDuel[ params[ 0 ] ] == 1)
 		return SendError(playerid, "That player is already invited to a duel!");


 	    if(IsNotWeapon( params[ 1 ] ) )
		return SendError( playerid, "Not allowed weapon ID");


	//if(	params[ 0 ]  == playerid)
 		//return SendError(playerid, "You can not duel yourself!");

    if(!IsValidWeapon( params[ 1 ] ) )
		return SendError( playerid, "Invalid weapon ID");

 

	new WeapName[ 32 ];


	DWP = params[ 1 ];
    GetWeaponName( params[ 1 ],WeapName,32 );

 	format(tString, sizeof(tString), "Invitation sent!~n~~n~Sent to:~b~~h~%s(~w~ID:%d~b~~h~)~n~~w~Weapon: ~r~~h~%s~n~~n~~w~Player must accept the duel invitation before starting a fight!",PlayerName2( params[ 0 ]), params[ 0 ],WeapName);
 	Info(playerid, tString, 13000);

 	format(tString, sizeof(tString), "Invitation received!~n~~n~Hoster:~b~~h~%s (~w~ID:%d~b~~h~)~n~~w~Weapon: ~r~~h~%s~n~~n~~w~Type ~b~~h~/duelaccept <playerid>~w~ to accept the invitation!",PlayerName2(playerid), playerid, WeapName);
 	Info( params[ 0 ], tString, 13000);

 	g_GotInvitedToDuel[ params[ 0 ]] = playerid;
	g_HasInvitedToDuel[playerid] = 1;

	return 1;
}
Reply
#2

What is going wrong. Give us some more information. And jezus, you are using more enters then your whole script. Try something like this:
pawn Код:
CMD:duel(playerid, params[])
{
    if ( sscanf( params, "ud", params[ 0 ], params[ 1 ] ) ) return SendUsage(playerid, "/duel [playerid] [weapon id]");
    if(g_HasInvitedToDuel[playerid] == 1) return SendError(playerid, "You already invited someone to a duel! ~n~Type ~b~~h~/duel~w~ to reset your invite");

    new tString[256];

    if (!IsPlayerConnected( params[ 0 ] )) return SendError(playerid, "Player is not connected.");
    if( g_HasInvitedToDuel[ params[ 0 ] ] == 1) return SendError(playerid, "That player is already invited to a duel!");
    if(IsNotWeapon( params[ 1 ] ) ) return SendError( playerid, "Not allowed weapon ID");

    //if(   params[ 0 ]  == playerid) return SendError(playerid, "You can not duel yourself!");

    if(!IsValidWeapon( params[ 1 ] ) ) return SendError( playerid, "Invalid weapon ID");

    new WeapName[32];
    new DWP = params[1];
   
    GetWeaponName( params[1],WeapName,32 );

    format(tString, sizeof(tString), "Invitation sent!~n~~n~Sent to:~b~~h~%s(~w~ID:%d~b~~h~)~n~~w~Weapon: ~r~~h~%s~n~~n~~w~Player must accept the duel invitation before starting a fight!",PlayerName2( params[ 0 ]), params[ 0 ],WeapName);
    Info(playerid, tString, 13000);

    format(tString, sizeof(tString), "Invitation received!~n~~n~Hoster:~b~~h~%s (~w~ID:%d~b~~h~)~n~~w~Weapon: ~r~~h~%s~n~~n~~w~Type ~b~~h~/duelaccept <playerid>~w~ to accept the invitation!",PlayerName2(playerid), playerid, WeapName);
    Info( params[ 0 ], tString, 13000);

    g_GotInvitedToDuel[ params[ 0 ]] = playerid;
    g_HasInvitedToDuel[playerid] = 1;

    return 1;
}
Reply
#3

Here
Reply
#4

i need /duel 0 "knife"
And not weapon id
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)