Help with zcmd
#1

Please help me fix these codes as when I try them it gives " Invalid ID " or " Player not connected "

slap -
Код:
CMD:slap(playerid, params[])
{
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
	new targetid;
	if(sscanf(params, "uz", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /slap [PlayerID/PartOfName]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: Player not connected!");
	else
	{
	new Float:SLX, Float:SLY, Float:SLZ;
	GetPlayerPos(targetid, SLX, SLY, SLZ);
	SetPlayerPos(targetid, SLX, SLY, SLZ+5);
	PlayerPlaySound(targetid, 1130, SLX, SLY, SLZ+5);
	new string[128];
	new pName[24], pTame[24];
	GetPlayerName(playerid,pName,24);
	GetPlayerName(targetid,pTame,24);
	format(string,sizeof string,""#COL_YELLOW"[SERVER]"#COL_LRED" %s has been slapped by Administrator %s.",pTame,pName);
	SendClientMessageToAll(COLOR_RED, string);
  	}
	return 1;
}
admin pm
Код:
//-----[Admin PM]-----
COMMAND:apm(playerid, params[])
{
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
    new str[128],id,pname[MAX_PLAYER_NAME], Message[128];
    if(sscanf(params, "us[128]", id, Message))SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /apm [PlayerID/PartOfName] [Message]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_ERROR, "Player not connected!");
    else
    {
        GetPlayerName(id, str, 24);
        format(str, sizeof(str), "[ADMIN] %s(%d): %s", str, id, Message);
        GetPlayerName(id, str, 24);
        format(str, sizeof(str), "[ADMIN] %s(%d): %s", str, id, Message);
        SendClientMessage(playerid, COLOR_YELLOW, str);
        GetPlayerName(playerid, pname, sizeof(pname));
        format(str, sizeof(str), "[ADMIN] %s(%d): %s", pname, playerid, Message);
        SendClientMessage(id, COLOR_YELLOW, str);
    }
    return 1;
}
freeze and unfreeze -

Код:
//-----[Freeze]-----
CMD:freeze(playerid, params[])
{
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
	new targetid, string[128];
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /freeze [PlayerID/PartOfName]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: Player not connected!");
	new pTargetName[24], pName[24];
	GetPlayerName(playerid,pName,24);
	GetPlayerName(targetid,pTargetName,24);
	format(string, sizeof(string), ""#COL_YELLOW"[SERVER]"#COL_LRED" %s has been frozen by Administrator %s.",pTargetName, pName);
	SendClientMessageToAll(COLOR_RED,string);
	TogglePlayerControllable(targetid, 0);
	return 1;
}

//-----[Unfreeze]-----
CMD:unfreeze(playerid, params[])
{
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
	new targetid, string[128];
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /unfreeze [PlayerID/PartOfName]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: Player not connected!");
	new pTargetName[24], pName[24];
	GetPlayerName(playerid,pName,24);
	GetPlayerName(targetid,pTargetName,24);
	format(string, sizeof(string), ""#COL_YELLOW"[SERVER]"#COL_LRED" %s has been unfrozen by Administrator %s.",pTargetName, pName);
	SendClientMessageToAll(COLOR_RED,string);
	TogglePlayerControllable(targetid, 1);
	return 1;
}
and guys mostly all the cmds are broken, Please tell me how to fix them if theres a common problem between them.
Reply
#2

pawn Код:
CMD:slap(playerid, params[])
{
    if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You are not authorized to use this command ");
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_SYNTAX, "[SYNTAX]: /slap [PlayerID/PartOfName]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]: Player not connected!");
    else
    {
    new Float:SLX, Float:SLY, Float:SLZ;
    GetPlayerPos(targetid, SLX, SLY, SLZ);
    SetPlayerPos(targetid, SLX, SLY, SLZ+5);
    PlayerPlaySound(targetid, 1130, SLX, SLY, SLZ+5);
    new string[128];
    new pName[24], pTame[24];
    GetPlayerName(playerid,pName,24);
    GetPlayerName(targetid,pTame,24);
    format(string,sizeof string,""#COL_YELLOW"[SERVER]"#COL_LRED" %s has been slapped by Administrator %s.",pTame,pName);
    SendClientMessageToAll(COLOR_RED, string);
    }
    return 1;
}

The others should work.. Make sure you compile the script. **Laugh**
Reply
#3

Freeze don't work, Can you connect with me through teamviewer and fix my admin system ?

Edit : /slap gives " player not connected " error.

Please fix it ?
Reply
#4

Lol, no i can't. Did you compile the script?
Reply
#5

Here is the freeze command with Zcmd and Sscanf, try it

First define the colors :-

Код:
#define Green 0x33AA33AA
#define Yellow 0xFFFF00AA
Now for the command

Код:
CMD:freeze(playerid, params[])
{
    new targetid, string[128], aname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, Yellow, "You must be an admin to use this cmd!");
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, Green, "Correct Usage: /freeze [PlayerID]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, Yellow, "This player is not connected to the server");
 	if(PlayerInfo[targetid][Adminlevel] < 1) return SendClientMessage(playerid, Red, "You can't freeze another admin");
	GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
	GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
	format(string, sizeof(string), "%s has frozen %s", aname, tname);
	TogglePlayerControllable(targetid, 0);
	SendClientMessageToAll(Yellow, string);
	GameTextForPlayer(targetid, "~r~Freezed!", 2000, 2);
	return 1;
}
Unfreeze command :-

Код:
CMD:unfreeze(playerid, params[])
{
    new targetid, string[128], aname[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, Yellow, "You must be an admin to use this cmd!");
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, Green, "Correct Usage: /unfreeze [PlayerID]");
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, Yellow, "This player is not connected to the server");
	GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
	GetPlayerName(targetid, tname, MAX_PLAYER_NAME);
	format(string, sizeof(string), "%s has unfrozen %s", aname, tname);
	TogglePlayerControllable(targetid, 1);
	SendClientMessageToAll(Yellow, string);
	GameTextForPlayer(targetid, "~g~Unfreezed", 2000, 2);
	return 1;
}
Sorry if I bumped, I hope it works with you
Reply
#6

Here are mine, they work perfectly.

Код:
CMD:freeze(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command!");
    new id, string[128];
    if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /freeze [ID]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player is not connected!");
    if(PlayerData[id][Frozen] == true) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player is already frozen!");
	format(string, sizeof(string), "ADMIN: You have been frozen by %s %s!", GetPlayerAdminStatus(playerid), GetPlayerRPName(playerid));
	SendClientMessage(id, COLOR_BLUE, string);
	format(string, sizeof(string), "ADMIN: %s has been frozen!", GetPlayerRPName(id));
	SendClientMessage(playerid, COLOR_BLUE, string);
	TogglePlayerControllable(id, false);
	PlayerData[id][Frozen] = true;
	return 1;
}

CMD:unfreeze(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command!");
    new id, string[128];
    if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /unfreeze [ID]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player is not connected!");
    if(PlayerData[id][Frozen] == false) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player is not even frozen!");
	format(string, sizeof(string), "ADMIN: You have been un-frozen by %s %s!", GetPlayerAdminStatus(playerid), GetPlayerRPName(playerid));
	SendClientMessage(id, COLOR_BLUE, string);
	format(string, sizeof(string), "ADMIN: %s has been un-frozen!", GetPlayerRPName(id));
	SendClientMessage(playerid, COLOR_BLUE, string);
	TogglePlayerControllable(id, true);
	PlayerData[id][Frozen] = false;
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)