PDA

View Full Version : Saving String


025Tadija
24/06/2015, 02:47 PM
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)

Dutheil
24/06/2015, 02:54 PM
I didn't well understand...

KillerDVX
24/06/2015, 02:58 PM
I didn't well understand...

Add me to the list..

Darkwood17
24/06/2015, 03:02 PM
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.

025Tadija
24/06/2015, 03:13 PM
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,



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..

KillerDVX
24/06/2015, 03:14 PM
Is that what you need ? :

dcmd_name(playerid,params[])
{
new ID;
new newnick[MAX_PLAYER_NAME];
if(sscanf(params, "us", ID, newnick))
{
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=0; i<MAX_PLAYERS; i++)
{
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,

025Tadija
24/06/2015, 03:19 PM
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?

Konstantinos
24/06/2015, 03:26 PM
CMD:myname(playerid, params[])
{
if(pInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "No permission.");
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /myname [your name]");
if(strlen(params) >= MAX_PLAYER_NAME) return SendClientMessage(playerid, COLOR_RED, "Too long name.");

strcpy(pInfo[playerid][pAdminName], params, MAX_PLAYER_NAME);
// change the size of "pAdminName" in the enum to MAX_PLAYER_NAME
return 1;
}

CMD:admins(playerid, params[])
{
new string[90];
SendClientMessage(playerid, COLOR_GREY, "Admins online:");

foreach(new i : Player) // your syntax was old and deprecated + it loops though connected players ONLY
{
if(pInfo[i][pAdmin] >= 1)
{
format(string, sizeof(string), "(ID: %d) %s %s (Admin level: %d)", i, PlayerName(i), pInfo[i][pAdminName], pInfo[i][pAdmin]);
SendClientMessage(playerid, pInfo[i][pDuty] ? COLOR_ORANGE : COLOR_GREY, string);
}
}
return 1;
}

KillerDVX
24/06/2015, 03:32 PM
Hope i'm right this time :

CMD:myname(playerid, params[])
{
new pname[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(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(playerid, pname, sizeof(pname));
SendClientMessage(playerid,COLOR_DEADCONNECT,"[ ADMINS ONLINE ]");
SendClientMessage(playerid,COLOR_WHITE,"-------------------------------------------------------------------");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(pInfo[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;
}

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

025Tadija
24/06/2015, 03:32 PM
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.

025Tadija
24/06/2015, 03:45 PM
Sry for double post, I made it, thanks to Konstantinos