zcmd problem
#1

hi samp
How can i transform this command from strcmd to zcmd?

Код HTML:
	if (strcmp(cmd, "/spec", true) == 0)
    {
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] < 1)
			{
				SendClientMessage(playerid, COLOR_ERROR, "You are not authorized to use that command.");
				return 1;
			}
			temp = strtok(cmdtext, idx);
			if(!strlen(temp))
			{
				SendClientMessage(playerid, COLOR_SYN, "Synthax: /spec [playerid/off]");
				return 1;
			}
			targetid = ReturnUser(temp);
			if(IsPlayerNPC(targetid)) return 1;
			if(strcmp("off", temp, true, strlen(temp)) == 0)
			{
			    if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
			    {
			        SendClientMessage(playerid, COLOR_ADMIN_INFO, "You are not spectating anyone");
					return 1;
			    }
				SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
				SendClientMessage(playerid, COLOR_ADMIN_INFO, "You are no longer spectating.");
			    TogglePlayerSpectating(playerid, 0);
			    SpectatedID[playerid] = INVALID_PLAYER_ID;
			    SpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
			    return 1;
			}
			if(IsPlayerConnected(targetid))
			{
				if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
				{
				    PlayerInfo[playerid][pInterior] = GetPlayerInterior(playerid);
				}
				SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(targetid));
				SetPlayerInterior(playerid, GetPlayerInterior(targetid));
				TogglePlayerSpectating(playerid, 1);
				SpectatedID[playerid] = targetid;
				new Float:X, Float:Y, Float:Z;
				new Float:health;
				GetPlayerHealth(targetid, health);
				new Float:armor;
				GetPlayerArmour(targetid, armor);GetPlayerPos(playerid, X, Y, Z);
				new cash =  GetPlayerMoney(targetid);
				if (PlayerInfo[playerid][pAdmin] >= 1)
				{
					format(strings, sizeof(strings), "Specing: [%d]%s [$%d] [H:%.0f] [A:%.0f]",targetid,PlayerName(targetid),cash,health,armor);
				}
				SendClientMessage(playerid, COLOR_GREEN, strings);
				if(IsPlayerInAnyVehicle(targetid))
				{
				    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(targetid));
				    SpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
				}
				else
				{
				    PlayerSpectatePlayer(playerid, targetid);
				    SpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_ERROR, "That player isn't active !");
			    return 1;
			}
	    }
	    return 1;
	}
To convert i need the sscanf2 include? or i can convert without him?
Reply
#2

Replace:
PHP код:
if (strcmp(cmd"/spec"true) == 0
with:
PHP код:
CMD:spec(playeridparams[]) 
Make sure you move the whole command outside any callback.
Also, it requires only ZCMD include, unless you have other elements which requires sscanf2.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)