Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define COLOR_GREY 0xBEBEBEAA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x300FFAAB
- #define COLOR_MEDIUMBLUE 0x63AFF00A
- forward OnPlayerUpdate(playerid);
- forward Encrypt(string[]);
- forward OnPlayerLogin(playerid,const string[]);
- enum pInfo
- {
- pPassword[128],
- pCash,
- pRank,
- pJob,
- pAdmin,
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new gPlayerLogged[MAX_PLAYERS];
- new gPlayerAccount[MAX_PLAYERS];
- main()
- {
- print("\n----------------------------------");
- print(" Saints Roleplay by FreddeN");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- SetGameModeText("Saints Roleplay 0.1 Beta");
- AddPlayerClassEx(1,280,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
- AddPlayerClassEx(1,281,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
- AddPlayerClassEx(1,284,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
- AddPlayerClassEx(1,283,610.8701,-585.9324,17.2266,184.1333,3,1,41,600,24,600);
- AddPlayerClassEx(1,288,610.8701,-585.9324,17.2266,184.1333,3,1,41,600,24,600);
- AddPlayerClassEx(1,282,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
- AddPlayerClassEx(1,265,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
- AddPlayerClassEx(1,267,1527.8987,-1677.8359,5.8906,269.2473,3,1,41,600,24,600);
- AddPlayerClassEx(1,286,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
- AddPlayerClassEx(1,163,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
- AddPlayerClassEx(1,164,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
- AddPlayerClassEx(1,147,1512.8138,-1460.1007,9.5000,180.3513,1,1,23,600,0,0);
- AddPlayerClassEx(1,71,1527.8987,-1677.8359,5.8906,269.2473,3,1,24,600,0,0);
- AddStaticVehicleEx(596,1600.7450,-1684.1527,5.6119,90.0628,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1601.2915,-1687.9362,5.6123,89.2274,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1600.8694,-1691.9482,5.6122,89.3799,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1600.8496,-1695.9462,5.6124,88.7060,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1601.3756,-1704.1774,5.6122,89.6655,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1595.6819,-1709.8339,5.6123,358.6504,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1587.4158,-1710.1013,5.6123,359.4464,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1583.4688,-1709.8881,5.6120,359.1869,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1578.8707,-1709.8186,5.6118,359.2487,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1570.5143,-1710.5320,5.6118,0.2044,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1545.0204,-1684.4034,5.6121,89.1754,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1544.5200,-1680.3934,5.6119,88.9024,0,1,3600); // LSPD Car
- AddStaticVehicleEx(596,1544.9509,-1663.1245,5.6123,87.8911,0,1,3600); // LSPD Car
- AddStaticVehicleEx(601,1564.9312,-1710.0203,5.6493,359.2724,1,1,3600); // LSPD Car
- AddStaticVehicleEx(427,1526.4474,-1645.8596,6.0224,178.7030,0,1,3600); // LSPD Car
- AddStaticVehicleEx(427,1530.6548,-1645.5239,6.0225,179.1615,0,1,3600); // LSPD Car
- AddStaticVehicleEx(523,1559.6531,-1695.8699,5.4701,139.9993,0,0,3600); // LSPD Car
- AddStaticVehicleEx(523,1562.0741,-1695.6327,5.4611,134.2440,0,0,3600); // LSPD Car
- AddStaticVehicleEx(523,1564.3621,-1695.4502,5.4618,133.7394,0,0,3600); // LSPD Car
- AddStaticVehicleEx(523,1566.4624,-1695.6405,5.4581,135.6852,0,0,3600); // LSPD Car
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- PlayerPlaySound(playerid,1185,0,0,0);
- switch(classid)
- {
- case 0:
- {
- GameTextForPlayer(playerid, "Police Officers", 3000, 5);
- {
- SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
- SetPlayerFacingAngle(playerid, 90.3791);
- SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
- SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 1:
- {
- GameTextForPlayer(playerid, "Police Officers", 3000, 5);
- {
- SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
- SetPlayerFacingAngle(playerid, 90.3791);
- SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
- SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 2:
- {
- GameTextForPlayer(playerid, "Police Officers", 3000, 5);
- {
- SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
- SetPlayerFacingAngle(playerid, 90.3791);
- SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
- SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 3:
- {
- GameTextForPlayer(playerid, "Police Officers", 3000, 5);
- {
- SetPlayerPos(playerid, 630.8762,-571.8481,16.3359);
- SetPlayerFacingAngle(playerid, 270.4885);
- SetPlayerCameraPos(playerid, 635.6525,-571.8395,16.3359);
- SetPlayerCameraLookAt(playerid, 630.8762,-571.8481,16.3359);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 4:
- {
- GameTextForPlayer(playerid, "~r~Sheriff~n~~w~None", 3000, 5);
- {
- SetPlayerPos(playerid, 630.8762,-571.8481,16.3359);
- SetPlayerFacingAngle(playerid, 270.4885);
- SetPlayerCameraPos(playerid, 635.6525,-571.8395,16.3359);
- SetPlayerCameraLookAt(playerid, 630.8762,-571.8481,16.3359);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 5:
- {
- GameTextForPlayer(playerid, "~r~Undersheriff~n~~w~None", 3000, 5);
- {
- SetPlayerPos(playerid, 630.8762,-571.8481,16.3359);
- SetPlayerFacingAngle(playerid, 270.4885);
- SetPlayerCameraPos(playerid, 635.6525,-571.8395,16.3359);
- SetPlayerCameraLookAt(playerid, 630.8762,-571.8481,16.3359);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 6:
- {
- GameTextForPlayer(playerid, "~r~Chief of Police~n~~w~FreddeN", 3000, 5);
- {
- SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
- SetPlayerFacingAngle(playerid, 90.3791);
- SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
- SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 7:
- {
- GameTextForPlayer(playerid, "~r~Assistant Chief~n~~w~Dre", 3000, 5);
- {
- SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
- SetPlayerFacingAngle(playerid, 90.3791);
- SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
- SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 8:
- {
- GameTextForPlayer(playerid, "FBI Agents", 3000, 5);
- {
- SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
- SetPlayerFacingAngle(playerid, 0.3747);
- SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
- SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 9:
- {
- GameTextForPlayer(playerid, "FBI Agents", 3000, 5);
- {
- SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
- SetPlayerFacingAngle(playerid, 0.3747);
- SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
- SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 10:
- {
- GameTextForPlayer(playerid, "FBI Agents", 3000, 5);
- {
- SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
- SetPlayerFacingAngle(playerid, 0.3747);
- SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
- SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 11:
- {
- GameTextForPlayer(playerid, "~r~Director~n~~w~None", 3000, 5);
- {
- SetPlayerPos(playerid, 1518.9713,-1449.9578,13.5469);
- SetPlayerFacingAngle(playerid, 0.3747);
- SetPlayerCameraPos(playerid, 1518.9800,-1445.4089,13.3828);
- SetPlayerCameraLookAt(playerid, 1518.9713,-1449.9578,13.5469);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_BLUE);
- }
- }
- case 12:
- {
- GameTextForPlayer(playerid, "Laws and Enforcements Cadets", 3000, 5);
- {
- SetPlayerPos(playerid, 1545.4467,-1675.6056,13.5604);
- SetPlayerFacingAngle(playerid, 90.3791);
- SetPlayerCameraPos(playerid, 1540.8021,-1675.6617,13.5513);
- SetPlayerCameraLookAt(playerid, 1545.4467,-1675.6056,13.5604);
- ApplyAnimation(playerid,"PLAYIDLES","TIME",4.1,1,1,1,1,1);
- SetPlayerColor(playerid, COLOR_MEDIUMBLUE);
- }
- }
- }
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, COLOR_GREY, "Welcome to Saints Roleplay");
- SendClientMessage(playerid, COLOR_GREY, "Saints Roleplay 0.1 Beta");
- new pName[MAX_PLAYER_NAME];
- new string[48];
- GetPlayerName(playerid, pName, sizeof(pName));
- format(string, sizeof(string), "%s has joined the server. (Joined)", pName);
- SendClientMessageToAll(COLOR_GREY, string);
- SendClientMessage(playerid, COLOR_WHITE, "Please register with /register <password> or login with /login <password>");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new pName[MAX_PLAYER_NAME], string[56];
- GetPlayerName(playerid, pName, sizeof(pName));
- switch(reason)
- {
- case 0: format(string, sizeof(string), "%s has left the server. (Timed Out)", pName);
- case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pName);
- case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pName);
- }
- SendClientMessageToAll(COLOR_GREY, string);
- OnPlayerUpdate(playerid);
- gPlayerLogged[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- PlayerPlaySound(playerid,1186,0,0,0);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerPrivmsg(playerid, recieverid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256];
- new idx;
- cmd = strtok(cmdtext, idx);
- new tmp[256];
- new playername[MAX_PLAYER_NAME];
- if (strcmp(cmd, "/kill", true) ==0 )
- {
- SetPlayerHealth(playerid, 0.0);
- }
- if (strcmp(cmd, "/login", true) ==0 )
- {
- if(IsPlayerConnected(playerid))
- {
- new tmppass[64];
- if(gPlayerLogged[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_GREY, " You are already logged in.");
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GREY, " USAGE: /login <password>");
- return 1;
- }
- strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
- Encrypt(tmppass);
- OnPlayerLogin(playerid,tmppass);
- }
- return 1;
- }
- if (strcmp(cmd, "/register", true)==0)
- {
- new string[265];
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GREY, "USAGE: /register <password>");
- return 1;
- }
- if (gPlayerAccount[playerid] == 1)
- {
- SendClientMessage(playerid, COLOR_GREY, " That name is already registered");
- return 1;
- }
- strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
- Encrypt(PlayerInfo[playerid][pPassword]);
- GetPlayerName(playerid, playername, sizeof(playername));
- format(string, sizeof(string), "%s.cer", playername);
- new File: file = fopen(string, io_read);
- if (file)
- {
- SendClientMessage(playerid, COLOR_GREY, " That name is already registered");
- fclose(file);
- return 1;
- }
- new File:hFile;
- hFile = fopen(string, io_append);
- new var[32];//
- format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
- PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
- format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
- format(var, 32, "Rank=%d\n",PlayerInfo[playerid][pRank]);fwrite(hFile, var);
- format(var, 32, "Job=%d\n",PlayerInfo[playerid][pJob]);fwrite(hFile, var);
- format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
- fclose(hFile);
- SendClientMessage(playerid, COLOR_WHITE, "Succesfully Registered!");
- SendClientMessage(playerid, COLOR_WHITE, "Next time you connect, type /login <password> to log in.");
- OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]);
- return 1;
- }
- if (strcmp(cmd, "/onduty", true) ==0 )
- {
- new str[256], pname[256];
- if(PlayerInfo[playerid][pRank] < 1) return SendClientMessage(playerid,0xFF0000FF, "Identification Error - You need LAE Rank 1 to do this.");
- if(GetPlayerTeam(playerid) != 1) return SendClientMessage(playerid,0xFF0000FF, "Identification Error - You are not a Police Officer.");
- GetPlayerName(playerid, pname, 256);
- format(str, 256, "Officer %s Is now on duty!", pname, cmdtext[7]);
- SendClientMessageToAll(COLOR_BLUE, str);
- return 1;
- }
- return 0;
- }
- public OnPlayerInfoChange(playerid)
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- 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 OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public Encrypt(string[])
- {
- for(new x=0; x < strlen(string); x++)
- {
- string[x] += (3^x) * (x % 15);
- if(string[x] > (0xff))
- {
- string[x] -= 64;
- }
- }
- return 1;
- }
- public OnPlayerLogin(playerid,const string[])
- {
- new pname2[MAX_PLAYER_NAME];
- new pname3[MAX_PLAYER_NAME];
- new string2[64];
- new string3[128];
- GetPlayerName(playerid, pname2, sizeof(pname2));
- format(string2, sizeof(string2), "%s.cer", pname2);
- new File: UserFile = fopen(string2, io_read);
- if (UserFile)
- {
- new valtmp[128];
- fread(UserFile, valtmp);strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
- if ((strcmp(PlayerInfo[playerid][pPassword], string, true, strlen(valtmp)-1) == 0))
- {
- new key[128],val[128];
- new Data[128];
- while(fread(UserFile,Data,sizeof(Data)))
- {
- key = ini_GetKey(Data);
- if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
- if( strcmp( key , "Rank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pRank] = strval( val ); }
- if( strcmp( key , "Job" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pJob] = strval( val ); }
- if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
- GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
- }
- fclose(UserFile);
- gPlayerLogged[playerid] = 1;
- gPlayerAccount[playerid] = 1;
- GetPlayerName(playerid, pname3, sizeof(pname3));
- format(string3, sizeof(string3), "Welcome %s, you have been succesfully logged in!", pname3);
- SendClientMessage(playerid, COLOR_WHITE,string3);
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " Password does not match your name");
- fclose(UserFile);
- }
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- if(gPlayerLogged[playerid])
- {
- new string3[32];
- new pname3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pname3, sizeof(pname3));
- format(string3, sizeof(string3), "%s.cer", pname3);
- new File: pFile = fopen(string3, io_write);
- if (pFile)
- {
- new var[32];
- format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
- fclose(pFile);
- new File: hFile = fopen(string3, io_append);
- PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
- format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
- format(var, 32, "Rank=%d\n",PlayerInfo[playerid][pRank]);fwrite(hFile, var);
- format(var, 32, "Job=%d\n",PlayerInfo[playerid][pJob]);fwrite(hFile, var);
- format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
- fclose(hFile);
- }
- }
- }
- return 1;
- }
- stock ini_GetKey( line[] )
- {
- new keyRes[128];
- keyRes[0] = 0;
- if ( strfind( line , "=" , true ) == -1 ) return keyRes;
- strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
- return keyRes;
- }
- stock ini_GetValue( line[] )
- {
- new valRes[128];
- valRes[0]=0;
- if ( strfind( line , "=" , true ) == -1 ) return valRes;
- strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
- return valRes;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment