/adminchat
#1

Hey guys how are you? i have a question, how can i do to make this cmd work, i made this but doesnt work i dont knwo why its always says USAGE: (/a)dmin [Admin Chat] , what can i do to solve it?

PHP код:
CMD:adminchat(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] > 1)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        new 
text[128];
        if(
sscanf(params"s[128]",text)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: (/a)dmin [Admin Chat]");
        
format(textsizeof(text), "%s %s: %s",GetAdminRank(playerid), nametext);
        
SendAdminMessage(COLOR_ADMINCHATtext);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_CORRECTION"You are not authorized to use this chat.");
    }
    return 
1;
}
CMD:a(playeridparams[])
{
  return 
cmd_adminchat(playeridparams);

Reply
#2

Change if(sscanf(params, "s[128]",text)) to if(!sscanf(params, "s[128]",text))
Reply
#3

Update your sscanf2 to the latest version, that should fix your issue. The sscanf part is ok. I had the same issue when I was using some older sscanf2.
Reply
#4

Quote:
Originally Posted by Kyle
Посмотреть сообщение
Change if(sscanf(params, "s[128]",text)) to if(!sscanf(params, "s[128]",text))
now it says"You are not authorized to use this chat."
Reply
#5

Quote:
Originally Posted by whadez
Посмотреть сообщение
Update your sscanf2 to the latest version, that should fix your issue. The sscanf part is ok. I had the same issue when I was using some older sscanf2.
1. His sscanf version is fine. Stop giving incorrect information. The sscanf line was incorrect.

Quote:
Originally Posted by Jaua10
Посмотреть сообщение
now it says"You are not authorized to use this chat."
Then it looks like this player is either rank 0 or rank 1.

If he is rank 1 and you wan to allow him to use the command do this:

if(PlayerInfo[playerid][pAdmin] > 1)

change to

if(PlayerInfo[playerid][pAdmin] >= 1)
Reply
#6

Quote:
Originally Posted by Kyle
Посмотреть сообщение
1. His sscanf version is fine. Stop giving incorrect information. The sscanf line was incorrect.



Then it looks like this player is either rank 0 or rank 1.

If he is rank 1 and you wan to allow him to use the command do this:

if(PlayerInfo[playerid][pAdmin] > 1)

change to

if(PlayerInfo[playerid][pAdmin] >= 1)
Damn...still saying "You are not authorized to use this chat."
Reply
#7

Try this:
PHP код:
CMD:adminchat(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] >= 1
    { 
        new 
name[MAX_PLAYER_NAME]; 
        
GetPlayerName(playeridnamesizeof(name)); 
        new 
text[128]; 
        if(
sscanf(params"s[128]",text)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: (/a)dmin [Admin Chat]"); 
        
format(textsizeof(text), "%s %s: %s",GetAdminRank(playerid), nametext); 
        
SendAdminMessage(COLOR_ADMINCHATtext); 
    } 
    else 
    { 
        
SendClientMessage(playeridCOLOR_CORRECTION"You are not authorized to use this chat."); 
    } 
    return 
1

CMD:a(playeridparams[]) 

  return 
cmd_adminchat(playeridparams); 

Here is the code for admin level 1+, you placed it to be 2+!
Reply
#8

Ok i now i make a kick cmd and it says "You are not authorized to use this cmd" why...

This is all my gm

PHP код:
********************************************************************************
                            
GRAND THEFT AUTO ROLEPLAY PROJECT
********************************************************************************
                                    
INCLUDES
*******************************************************************************/
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <YSI\y_ini>
/********************************************************************************
                                    DEFINES
*******************************************************************************/
#define COLOR_SUCCESS                   0x33CCFFAA
#define COLOR_DO-ME                   0xC2A2DA00
#define COLOR_S-C-B-OOC               0xE0FFFFAA
#define COLOR_ADMINCHAT               0x8080FFFF
#define COLOR_GANGCHAT                   0xF4A419FF
#define COLOR_FAMILYCHAT              0x00FFFFFF
#define COLOR_ADVERTISE               0x33AA3300
#define COLOR_MOLE-TXT-MEGAPHONE      0xFFFF00AA
#define COLOR_GOV-AGOV                0x2641FE00
#define COLOR_ALLDEPT                   0xFF828200
#define COLOR_CORRECTION              0xB4B5B7FF
#define COLOR_LIGHTRED                  0xFF6347AA
/********************************************************************************
                                    STOCK DE CHATS
*******************************************************************************/
stock SendRangedMessage(sourceidcolormessage[], Float:range) {
    new 
Float:xFloat:yFloatz;
    
GetPlayerPos(sourceidxyz);
    for (new 
ii 0ii MAX_PLAYERSii++) {
            if(
GetPlayerVirtualWorld(sourceid) == GetPlayerVirtualWorld(ii)) {
                if(
IsPlayerInRangeOfPoint(iirangexyz)) {
                    
SendClientMessage(iicolormessage);
                }
            }
        }
    }
/*******************************************************************************
                                ADMIN RANK NAMES
*******************************************************************************/
enum aInfo
{
    
pAdmin
}
new 
PlayerInfo[MAX_PLAYERS][aInfo];
stock GetAdminRank(playerid)
{
    new 
arank[64];
    switch(
PlayerInfo[playerid][pAdmin])
    {
        case 
6arank "Server Owner";
        case 
5arank "Head Admin";
        case 
4arank "Management";
        case 
3arank "Chief Moderator";
        case 
2arank "Class 2 Moderator";
        case 
1arank "Moderator";
        default: 
arank "None";
    }
    return 
arank;
}
stock SendAdminMessage(colstring[])
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
PlayerInfo[i][pAdmin] > 0)
            
SendClientMessage(icolstring);
    }
    return 
1;
}
main()
{
    print(
"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~");
     print(
"~                          ~");
    print(
"~   WELCOME MR. UGAS       ~");
     print(
"~                          ~");
    print(
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
public 
OnGameModeInit()
{
    
SetGameModeText("Light Roleplay");
    
UsePlayerPedAnims(); // ESTILO DE CORRER NORMAL
    
DisableInteriorEnterExits(); // QUITAR FLECHA AMARILLA DE ENTRADA Y SALIDA
    
EnableStuntBonusForAll(0); //QUITAR BONIFICACION POR ACROBACIA 0 PARA DESHABILITAR 1 PARA HABILITAR
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    
/*******************************************************************************
                                LSPD VEHICLES
*******************************************************************************/
    
AddStaticVehicle(523,1527.3163,-1685.1029,5.4608,271.5119,0,1);
    
AddStaticVehicle(523,1527.5216,-1682.6748,5.4604,272.3541,0,1);
    
AddStaticVehicle(523,1596.7095,-1711.5623,5.4607,1.0969,0,1);
    
AddStaticVehicle(523,1594.4382,-1711.6831,5.4607,1.6969,0,1);
    
AddStaticVehicle(599,1585.2042,-1671.6952,6.1334,270.4819,0,1);
    
AddStaticVehicle(599,1585.1556,-1667.5024,6.1309,270.3976,0,1);
    
AddStaticVehicle(596,1601.7969,-1683.9301,5.6154,89.1779,0,1);
    
AddStaticVehicle(596,1601.7103,-1687.9463,5.6154,88.7239,0,1);
    
AddStaticVehicle(596,1601.6028,-1692.1003,5.6155,89.4667,0,1);
    
AddStaticVehicle(596,1601.5330,-1696.1677,5.6163,89.7926,0,1);
    
AddStaticVehicle(596,1601.4321,-1700.2527,5.6159,90.3063,0,1);
    
AddStaticVehicle(596,1601.3737,-1704.3434,5.6166,88.8093,0,1);
    
AddStaticVehicle(596,1591.6672,-1710.2681,5.6114,0.1604,0,1);
    
AddStaticVehicle(596,1587.4830,-1710.3685,5.6157,1.1158,0,1);
    
AddStaticVehicle(596,1583.3774,-1710.4376,5.6166,0.6561,0,1);
    
AddStaticVehicle(596,1578.5658,-1710.4767,5.6166,359.4766,0,1);
    
AddStaticVehicle(596,1574.4263,-1710.4875,5.6152,359.8694,0,1);
    
AddStaticVehicle(596,1570.2677,-1710.5610,5.5683,0.5529,0,1);
    
AddStaticVehicle(427,1564.6061,-1710.8301,6.0496,0.6901,0,1);
    
AddStaticVehicle(523,1559.8895,-1710.8851,5.4632,357.4979,0,1);
    
AddStaticVehicle(523,1557.4730,-1712.1764,5.4604,5.0780,0,1);
    
AddStaticVehicle(596,1528.7706,-1687.9839,5.6145,269.6358,0,1);
    
AddStaticVehicle(596,1544.3862,-1684.3945,5.6158,89.1681,0,1);
    
AddStaticVehicle(596,1544.5164,-1680.3345,5.6153,89.9007,0,1);
    
AddStaticVehicle(596,1544.6355,-1676.2106,5.6159,89.6448,0,1);
    
AddStaticVehicle(596,1544.7999,-1672.1379,5.5521,88.9068,0,1);
    
AddStaticVehicle(596,1544.9031,-1667.8500,5.6150,89.7383,0,1);
    
AddStaticVehicle(596,1544.9717,-1663.1096,5.5480,89.7992,0,1);
    
AddStaticVehicle(596,1545.0317,-1659.1681,5.5494,89.8932,0,1);
    
AddStaticVehicle(596,1545.1237,-1655.1316,5.5508,89.4096,0,1);
    
AddStaticVehicle(596,1545.2240,-1651.0857,5.6151,89.2011,0,1);
    
AddStaticVehicle(528,1538.6281,-1644.6017,5.8624,181.3446,0,1);
    
AddStaticVehicle(528,1534.6387,-1644.6354,5.8654,181.2640,0,1);
    
AddStaticVehicle(601,1530.5455,-1644.7382,5.6868,180.6024,0,1);
    
AddStaticVehicle(601,1526.4720,-1644.5981,5.6867,179.1370,0,1);
    
AddStaticVehicle(497,1561.5265,-1657.4136,28.5733,90.2463,0,0);
    
AddStaticVehicle(497,1551.5613,-1644.3290,28.5232,88.7546,0,0);
    
AddStaticVehicle(497,1552.5212,-1706.2377,28.5715,87.8549,0,0);
    
AddStaticVehicle(497,1561.3627,-1691.7267,28.5730,90.6360,0,0);
/*******************************************************************************
                                FBI VEHICLES
*******************************************************************************/
     
AddStaticVehicle(490,1761.6815,-1660.3876,13.6885,90.0116,0,0);
    
AddStaticVehicle(490,1761.7026,-1664.3705,13.6885,89.9007,0,0);
    
AddStaticVehicle(490,1761.7349,-1668.5120,13.6891,90.6184,0,0);
    
AddStaticVehicle(415,1762.1243,-1672.9875,13.3860,89.9096,0,0);
    
AddStaticVehicle(415,1762.1129,-1676.4563,13.3834,89.5654,0,0);
    
AddStaticVehicle(415,1762.1403,-1680.0005,13.3939,89.6049,0,0);
    
AddStaticVehicle(451,1764.1061,-1640.6316,14.1184,125.3097,0,0);
    
AddStaticVehicle(447,1783.0109,-1647.6302,39.1222,129.6716,0,0);
    
AddStaticVehicle(447,1793.9280,-1663.9199,39.1218,128.4076,0,0);
    
AddStaticVehicle(497,1790.1617,-1655.4030,39.2861,125.9664,0,0);
/*******************************************************************************
                                SAMFD VEHICLES
*******************************************************************************/
    
AddStaticVehicle(416,1181.4211,-1308.7296,13.8054,271.3664,1,3);
    
AddStaticVehicle(416,1181.8961,-1338.8051,13.8854,269.0506,1,3);
    
AddStaticVehicle(407,1211.2191,-1323.5789,13.7093,359.3416,3,1);
    
AddStaticVehicle(407,2038.4838,-1419.7720,17.3101,181.2136,3,1);
    
AddStaticVehicle(416,2016.2207,-1412.3525,17.1424,181.2251,1,3);
    
AddStaticVehicle(416,2010.9615,-1412.3804,17.1424,179.8213,1,3);
    
AddStaticVehicle(416,2005.8264,-1412.4191,17.1424,180.6365,1,3);
    
AddStaticVehicle(563,2055.7993,-1416.5199,49.0409,88.5873,3,1);
    
AddStaticVehicle(563,2058.0964,-1431.6517,49.0416,90.3616,3,1);
    
AddStaticVehicle(563,1159.8182,-1318.3346,32.2016,267.5297,3,1);
    
AddStaticVehicle(563,1159.3705,-1304.5052,32.2030,270.9046,3,1);
/*******************************************************************************
                                SANews VEHICLES
*******************************************************************************/
    
AddStaticVehicle(488,741.9053,-1371.1826,25.8690,0.1854,1,2);
    
AddStaticVehicle(582,754.9459,-1334.9719,13.5945,181.4745,1,2);
    
AddStaticVehicle(582,759.5004,-1334.8759,13.6002,181.9060,1,2);
    
AddStaticVehicle(582,764.1581,-1334.9065,13.5960,179.8305,1,2);
    
AddStaticVehicle(582,768.5367,-1334.7930,13.5959,180.3463,1,2);
    
AddStaticVehicle(582,781.9040,-1343.5404,13.5914,89.6859,1,2);
    
AddStaticVehicle(582,781.8544,-1348.7742,13.5929,89.9967,1,2);
    
AddStaticVehicle(582,781.9462,-1354.2291,13.5944,90.7076,1,2);
    
AddStaticVehicle(488,735.5504,-1371.2444,25.8669,358.6932,1,2);
    
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    return 
1;
}
public 
OnVehicleSpawn(vehicleid)
{
    return 
1;
}
public 
OnVehicleDeath(vehicleidkillerid)
{
    return 
1;
}
public 
OnPlayerText(playeridtext[])
{
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/mycommand"cmdtexttrue10) == 0)
    {
        
// Do something here
        
return 1;
    }
    return 
0;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    return 
1;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
    return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    return 
1;
}
public 
OnPlayerEnterCheckpoint(playerid)
{
    return 
1;
}
public 
OnPlayerLeaveCheckpoint(playerid)
{
    return 
1;
}
public 
OnPlayerEnterRaceCheckpoint(playerid)
{
    return 
1;
}
public 
OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 
1;
}
public 
OnRconCommand(cmd[])
{
    return 
1;
}
public 
OnPlayerRequestSpawn(playerid)
{
    return 
1;
}
public 
OnObjectMoved(objectid)
{
    return 
1;
}
public 
OnPlayerObjectMoved(playeridobjectid)
{
    return 
1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    return 
1;
}
public 
OnVehicleMod(playeridvehicleidcomponentid)
{
    return 
1;
}
public 
OnVehiclePaintjob(playeridvehicleidpaintjobid)
{
    return 
1;
}
public 
OnVehicleRespray(playeridvehicleidcolor1color2)
{
    return 
1;
}
public 
OnPlayerSelectedMenuRow(playeridrow)
{
    return 
1;
}
public 
OnPlayerExitedMenu(playerid)
{
    return 
1;
}
public 
OnPlayerInteriorChange(playeridnewinterioridoldinteriorid)
{
    return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    return 
1;
}
public 
OnRconLoginAttempt(ip[], password[], success)
{
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    return 
1;
}
public 
OnPlayerStreamIn(playeridforplayerid)
{
    return 
1;
}
public 
OnPlayerStreamOut(playeridforplayerid)
{
    return 
1;
}
public 
OnVehicleStreamIn(vehicleidforplayerid)
{
    return 
1;
}
public 
OnVehicleStreamOut(vehicleidforplayerid)
{
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    return 
1;
}
public 
OnPlayerClickPlayer(playeridclickedplayeridsource)
{
    return 
1;
}
/*******************************************************************************
                                    CHATS
*******************************************************************************/
CMD:ooc(playeridparams[])
{
    new 
sendername[MAX_PLAYER_NAME], string[56];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_CORRECTION,"USAGE: (/o)oc [Out-of-Character Chat]");
    
format(stringsizeof(string), "(( %s: %s ))"sendernameparams);
    
SendClientMessageToAll(COLOR_S-C-B-OOCstring);
    return 
1;
}
CMD:o(playeridparams[])
{
  return 
cmd_ooc(playeridparams);
}
CMD:b(playeridparams[])
{
    new 
sendername[MAX_PLAYER_NAME], string[56];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: /b [Local OOC Chat]");
    
format(stringsizeof(string), "%s Says: (( %s ))"sendernameparams);
    
SendRangedMessage(playeridCOLOR_S-C-B-OOCstring20);
    return 
1;
}
CMD:close(playeridparams[])
{
    new 
sendername[MAX_PLAYER_NAME], string[56];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: /©lose [Close Chat Text]");
    
format(stringsizeof(string), "%s Says: %s"sendernameparams);
    
SendRangedMessage(playeridCOLOR_S-C-B-OOCstring3);
    return 
1;
}
CMD:c(playeridparams[])
{
  return 
cmd_close(playeridparams);
}
CMD:shout(playeridparams[])
{
    new 
sendername[MAX_PLAYER_NAME], string[56];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: (/s)hout [Local Chat]");
    
format(stringsizeof(string), "%s Shouts: %s!"sendernameparams);
    
SendRangedMessage(playeridCOLOR_S-C-B-OOCstring25);
    return 
1;
}
CMD:s(playeridparams[])
{
  return 
cmd_shout(playeridparams);
}
CMD:me(playeridparams[])
{
    new 
sendername[MAX_PLAYER_NAME], string[56];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: /me [Action]");
    
format(stringsizeof(string), "* %s %s *"sendernameparams);
    
SendRangedMessage(playeridCOLOR_DO-MEstring30);
    return 
1;
}
CMD:do(playeridparams[])
{
    new 
sendername[MAX_PLAYER_NAME], string[56];
    
GetPlayerName(playeridsendernamesizeof(sendername));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: /do [Action]");
    
format(stringsizeof(string), "** %s %s **"sendernameparams);
    
SendRangedMessage(playeridCOLOR_DO-MEstring30);
    return 
1;
}
CMD:adminchat(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 1)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        new 
text[128];
        if(
sscanf(params"s[128]",text)) return SendClientMessage(playeridCOLOR_CORRECTION"USAGE: (/a)dmin [Admin Chat]");
        
format(textsizeof(text), "%s %s: %s",GetAdminRank(playerid), nametext);
        
SendAdminMessage(COLOR_ADMINCHATtext);
    }
    else
    {
        
SendClientMessage(playeridCOLOR_CORRECTION"You are not authorized to use this chat.");
    }
    return 
1;
}
CMD:a(playeridparams[])
{
  return 
cmd_adminchat(playeridparams);
}
CMD:kick(playerid,params[])
{
    new 
id,name1[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME];
    if(!
PlayerInfo[playerid][pAdmin] >= 1) return SendClientMessage(playeridCOLOR_CORRECTION,"You are not authorized to use this command.");
    if(
sscanf(params,"us[128]",id,params)) return SendClientMessage(playeridCOLOR_CORRECTION,"USAGE: /kick [Playerid/Partofname] [Reason]");
    if(!
IsPlayerConnected(id)) return SendClientMessage(playeridCOLOR_CORRECTION,"Player is not connected");
    
GetPlayerName(playerid,name1,sizeof(name1));
    
GetPlayerName(id,name2,sizeof(name2));
    
format(params,129"Notice: %s was kicked by %s, reason: %s (%d-%d-%d)",name2,name1,params);
    
SendClientMessageToAll(COLOR_LIGHTRED,params);
    
Kick(id);
    return 
1;

I cant see the solution...
Reply
#9

Quote:
Originally Posted by Kyle
Посмотреть сообщение
1. His sscanf version is fine. Stop giving incorrect information. The sscanf line was incorrect.



Then it looks like this player is either rank 0 or rank 1.

If he is rank 1 and you wan to allow him to use the command do this:

if(PlayerInfo[playerid][pAdmin] > 1)

change to

if(PlayerInfo[playerid][pAdmin] >= 1)
Just because you have no experience with sscanf doesn't mean that what I'm saying is incorrect. All of my gamemodes were built like this, and it never had any problems whatsoever. If you are not sure about something better ask than say something stupid and make yourself look unexperienced.
Reply
#10

Код:
if(!PlayerInfo[playerid][pAdmin] >= 1)
! means if the statement is false.
so you're like saying do that if player rank is lower than 1.
remove the !
PHP код:
if(PlayerInfo[playerid][pAdmin] >= 1
@Kyle , no sscanf line is completely fine. if you ever used sscanf would have realized that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)