PDA

View Full Version : Admin Message


Tuntun
14/07/2012, 01:17 PM
Hello
i need a help with a new script...
i need help with a admin message system... the cmd's : /admin [message]
if players do /admin Hi so the message will be go to admin in a small box.. and the admins can do /ram playerid/player
name [message]... please help me with create this cmd's...

Devilxz97
14/07/2012, 01:36 PM
like /a ?
if yes there u are , use ZCMD

CMD:a(playerid, params[])
{
new string[512];
new pName[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pAdmin] >= 1) //i dont know your admin variables xD
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1)
GetPlayerName(playerid, Name, sizeof(Name));
format(string, sizeof(string), "[ADMINCHAT]:%s ( %s )", pName, params);
SendClientMessage(i, COLOR_WHITE,string);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "[ERROR]:You need to be an [ADMIN] to use this Commands!");
}
return 1;
}

if works Rep+ me :D

[MM]RoXoR[FS]
14/07/2012, 01:38 PM
Get dcmd and sscanf if you dont have from here.
SSCANF : Here (http://forum.sa-mp.com/showthread.php?t=120356)
DCMD :
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

Add this at top of your script.

#include <sscanf2>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

Under OnPlayerCommandText Add

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}

Admin Command

dcmd_admin(playerid,params[])
{
new msg[120];
if(sscanf(params,"s[120]",msg)) return SendClientMessage(playerid,-1,"Correct Usage : /admin [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"%s(ID:%d) : %s",name,playerid,msg);
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i) || pInfo[i][Admin]>=1)
SendClientMessage(i,-1,msg);
}
}
return 1;
}

RAM command

dcmd_ram(playerid,params[])
{
new msg[200],targetid;
if(pInfo[playerid][Admin]< 1 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
SendClientMessage(targetid,-1,msg);
return 1;
}


Remember to REPLACE pInfo[playerid][Admin] with your Admin Variable

Tuntun
14/07/2012, 01:43 PM
1 error
F:\Copy of test.pwn(13) : warning 203: symbol is never used: "dcmd_ram"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.

Devilxz97
14/07/2012, 01:48 PM
1 error
F:\Copy of test.pwn(13) : warning 203: symbol is never used: "dcmd_ram"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}

Tuntun
14/07/2012, 01:56 PM
Like this?:
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}
dcmd_ram(playerid,params[])
{
new msg[200],targetid;
if(pInfo[playerid][Admin]< 1 || !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
SendClientMessage(targetid,-1,msg);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}

[MM]RoXoR[FS]
14/07/2012, 01:59 PM
#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}

dcmd_admin(playerid,params[])
{
new msg[120];
if(sscanf(params,"s[120]",msg)) return SendClientMessage(playerid,-1,"Correct Usage : /admin [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"%s(ID:%d) : %s",name,playerid,msg);
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i) || pInfo[i][Admin]>=1)
SendClientMessage(i,-1,msg);
}
}
return 1;
}
dcmd_ram(playerid,params[])
{
new msg[200],targetid;
if(pInfo[playerid][Admin]< 1 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
SendClientMessage(targetid,-1,msg);
return 1;
}

Tuntun
14/07/2012, 02:07 PM
F:\Copy of test.pwn(23) : error 017: undefined symbol "pInfo"
F:\Copy of test.pwn(23) : warning 215: expression has no effect
F:\Copy of test.pwn(23) : error 001: expected token: ";", but found "]"
F:\Copy of test.pwn(23) : error 029: invalid expression, assumed zero
F:\Copy of test.pwn(23) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

clarencecuzz
14/07/2012, 02:10 PM
Change line 23 to:
if(IsPlayerAdmin(i))

Tuntun
14/07/2012, 02:20 PM
#include <a_samp>
#include <sscanf2>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(admin,5,cmdtext);//admin command
dcmd(ram,3,cmdtext);//ram command
return 0;
}

dcmd_admin(playerid,params[])
{
new msg[120];
if(sscanf(params,"s[120]",msg)) return SendClientMessage(playerid,-1,"Correct Usage : /admin [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"%s(ID:%d) : %s",name,playerid,msg);
for(new i=0;i<MAX_PLAYERS;++i)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i))
SendClientMessage(i,-1,msg);
}
}
return 1;
}
dcmd_ram(playerid,params[])
{
new msg[200],targetid;
if(pInfo[playerid][Admin]< 1 && !IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"You are not allowed to use this cmd");
if(sscanf(params,"us[120]",targetid,msg)) return SendClientMessage(playerid,-1,"Correct Usage : /ram [id] [message]");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(msg,sizeof(msg),"[ADMIN] %s : %s",name,msg);
SendClientMessage(targetid,-1,msg);
return 1;
}
And the Errors:

F:\Copy of test.pwn(31) : error 017: undefined symbol "pInfo"
F:\Copy of test.pwn(31) : warning 215: expression has no effect
F:\Copy of test.pwn(31) : error 001: expected token: ";", but found "]"
F:\Copy of test.pwn(31) : error 029: invalid expression, assumed zero
F:\Copy of test.pwn(31) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.