Saving String
#1

Hey guys, I'm new in scripting and I want to make a command that will save string, and then show it later after using other command.
I wanted to create admin command /myname [your name], so you type like /myname 025Tadija, and after you type it, you can see it after u use /admins, so that would be like

Admins online:
(ID: 5) Tadija_Tadija (025Tadija) (Admin level: 5)

if you dont type your name after login that would be

Admins online:
(ID: 5) Tadija_Tadija (Admin level: 5)
Reply
#2

I didn't well understand...
Reply
#3

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
I didn't well understand...
Add me to the list..
Reply
#4

He means to set another player name and show it in the /admins dialog.
First of all you have to give us your /admins command.
Reply
#5

pawn Код:
CMD:admins(playerid, params[])
{
    new
        string[50];
       
    SendClientMessage(playerid, COLOR_GREY, "Admins online:");
    foreach(Player, i)
    {
        if(IsPlayerConnected(i))
        {
            if(pInfo[i][pAdmin] >= 1)
            {
                if(pInfo[i][pDuty] == true)
                {

                        format(string, sizeof(string),"(ID: %d) %s(Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
                        SendClientMessage(playerid, COLOR_ORANGE, string);
                   
                }
               
                else
                {

                        format(string, sizeof(string),"(ID: %d) %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdmin]);
                        SendClientMessage(playerid, COLOR_GREY, string);

                }
            }
        }
    }
    return 1;
}
that is my admins command, and I want new command /myname and when I type /myname [my forum name] that shows into /admins, I gues you understand it now..but I dont know how to make a command, I made it couple months ago with format, but that is slow as hell,


pawn Код:
CMD:myname(playerid, params[]) // ne radi
{

    if(pInfo[playerid][pAdmin] < 1)
        return SendClientMessage(playerid, COLOR_RED, "No permission.");
       
    if(isnull(params))
        return SendClientMessage(playerid, -1, "Usage: /myname [your name]");
       
    strcpy(pInfo[playerid][pAdminName], params, 10);
   
       
    return 1;
       
   
}
that command I tried but doesn't work.


That /admins command is withouth this /myname stuff..
Reply
#6

Is that what you need ? :

PHP код:
dcmd_name(playerid,params[])
{
    new 
ID;
    new 
newnick[MAX_PLAYER_NAME];
    if(
sscanf(params"us"IDnewnick))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"/name [Pseudo/ID] [Name].");
        return 
1;
    }
    
SetPlayerName(ID,newnick);
    
GameTextForPlayer(ID,"~r~Name's changed",3000,5);
     return 
1;
}
dcmd_admins(playerid,params[])
{
    
#pragma unused params
    
new string[138];
    
SendClientMessage(playerid,COLOR_DEADCONNECT,"[ ADMINS ONLINE ]");
    
SendClientMessage(playerid,COLOR_WHITE,"-------------------------------------------------------------------");
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerAdmin(i))
            {
            
format(string,sizeof(string),"Admin %s(%d) : Admin Level (%d)",PlayerName(i),i,AdminLevel(i)));
            
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
        }
    
SendClientMessage(playerid,COLOR_WHITE,"-------------------------------------------------------------------");
    return 
1;
}
stock AdminLevel(targetid)
{
    new 
adlvl[10];
    if(
PlayerInfo[targetid][pAdmin] == 0) { adlvl "0"; }
    if(
PlayerInfo[targetid][pAdmin] == 1) { adlvl "1"; }
    if(
PlayerInfo[targetid][pAdmin] == 2) { adlvl "2"; }
    if(
PlayerInfo[targetid][pAdmin] == 3) { adlvl "3"; }
    if(
PlayerInfo[targetid][pAdmin] == 4) { adlvl "4"; }
    if(
PlayerInfo[targetid][pAdmin] == 5) { adlvl "5"; }
    if(
PlayerInfo[targetid][pAdmin] == 6) { adlvl "6"; }
    return 
adlvl;

KillerDVX,
Reply
#7

No, I want command "Usage: /myname [YOUR FORUM NAME]" so if you are admin you will type

/myname KillerDVX

and when some other player type /admins he will be able to see this
Admins online:
(ID: 231) Killer_Dvx (KillerDVX) (Admin level: 2) that is example.
(ID: 21) Tadija_Samp (025Tadija) (Admin level: 3) that is my name example
(ID: 10) Name_Surname (Admin level: 5) So. this guy didn't use /myname command, so there is no his FORUM name on /admins command..

I gues you understand it now?
Reply
#8

PHP код:
CMD:myname(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] < 1) return SendClientMessage(playeridCOLOR_RED"No permission.");
    if(
isnull(params)) return SendClientMessage(playerid, -1"Usage: /myname [your name]");
    if(
strlen(params) >= MAX_PLAYER_NAME) return SendClientMessage(playeridCOLOR_RED"Too long name.");
    
    
strcpy(pInfo[playerid][pAdminName], paramsMAX_PLAYER_NAME);
    
// change the size of "pAdminName" in the enum to MAX_PLAYER_NAME
    
return 1;
}
CMD:admins(playeridparams[])
{
    new 
string[90];
    
SendClientMessage(playeridCOLOR_GREY"Admins online:");
    
    foreach(new 
Player// your syntax was old and deprecated + it loops though connected players ONLY
    
{
        if(
pInfo[i][pAdmin] >= 1)
        {
            
format(stringsizeof(string), "(ID: %d) %s %s (Admin level: %d)"iPlayerName(i), pInfo[i][pAdminName], pInfo[i][pAdmin]);
            
SendClientMessage(playeridpInfo[i][pDuty] ? COLOR_ORANGE COLOR_GREYstring);
        }
    }
    return 
1;

Reply
#9

Hope i'm right this time :

PHP код:
CMD:myname(playeridparams[])
{
    new 
pname[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
     
format(string,sizeof(string),"Your name is : %s(%d).",pname,playerid);
     
SendClientMessage(killerid,COLOR_RED,string);
     return 
1;
}
dcmd_admins(playerid,params[])
{
    
#pragma unused params
    
new string[138];
    new 
pname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    
SendClientMessage(playerid,COLOR_DEADCONNECT,"[ ADMINS ONLINE ]");
    
SendClientMessage(playerid,COLOR_WHITE,"-------------------------------------------------------------------");
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
pInfo[i][pAdmin] == 1)
            {
            
format(string,sizeof(string),"Admin %s(%d) : Admin Level (%d)",pname(i),i,AdminLevel(i)));
            
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
        }
    
SendClientMessage(playerid,COLOR_WHITE,"-------------------------------------------------------------------");
    return 
1;
}
stock AdminLevel(targetid)
{
    new 
adlvl[10];
    if(
PlayerInfo[targetid][pAdmin] == 0) { adlvl "0"; }
    if(
PlayerInfo[targetid][pAdmin] == 1) { adlvl "1"; }
    if(
PlayerInfo[targetid][pAdmin] == 2) { adlvl "2"; }
    if(
PlayerInfo[targetid][pAdmin] == 3) { adlvl "3"; }
    if(
PlayerInfo[targetid][pAdmin] == 4) { adlvl "4"; }
    if(
PlayerInfo[targetid][pAdmin] == 5) { adlvl "5"; }
    if(
PlayerInfo[targetid][pAdmin] == 6) { adlvl "6"; }
    return 
adlvl;
}[/
i


EDIT: You can choose my stock, or make your own admin duty.
Reply
#10

That pDuty means if he is on duty > show his name orange, if he is not on duty, show his normal color (in this case it is COLOR_GREY)

And I want to make same thing for PAdminName if he has pAdminName, show it, if he dont have, dont show anything.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)