Making this smaller
#1

Hey guys. I'm using a script where you can make people cops..
But my script for that is waaaaay to long.
I have 9 cop levels.

They are like this:
Код:
dcmd_lspd2(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


 if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd2 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 2");
	PlayerInfo[target][LSPDLEVEL] = 2;
	SendClientMessage(target,red,"You are now lspd rank 2");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd3(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd3 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 3");
	PlayerInfo[target][LSPDLEVEL] = 3;
	SendClientMessage(target,red,"You are now lspd rank 3");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd4(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd4 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 4");
	PlayerInfo[target][LSPDLEVEL] = 4;
	SendClientMessage(target,red,"You are now lspd rank 4");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd5(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd5 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 5");
	PlayerInfo[target][LSPDLEVEL] = 5;
	SendClientMessage(target,red,"You are now lspd rank 5");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd6(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd6 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 6");
	PlayerInfo[target][LSPDLEVEL] = 6;
	SendClientMessage(target,red,"You are now lspd rank 6");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd7(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd7 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 7");
	PlayerInfo[target][LSPDLEVEL] = 7;
	SendClientMessage(target,red,"You are now lspd rank 7");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd8(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd8 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 8");
	PlayerInfo[target][LSPDLEVEL] = 8;
	SendClientMessage(target,red,"You are now lspd rank 8");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}

dcmd_lspd9(playerid, params[]) {

  new PName[24];
	GetPlayerName(playerid, PName, 24);


	if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
	{
	new target;
 	target = strval(params);
	if(!params[0]) return SendClientMessage(playerid, 0x2641FEAA, "ERROR: /lspd9 <playerid>");
  SendClientMessage(playerid,red,"You've made him/her LSPD rank 9");
	PlayerInfo[target][LSPDLEVEL] = 9;
	SendClientMessage(target,red,"You are now lspd rank 9");
	}
	else
	SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}
Can anyone make these levels above here just in 1 command?
Like /lspd [id] [rank]?


Thanks in advance
Reply
#2

Код:
dcmd_setlspdlevel(playerid, params[]) 
{
 if(PlayerInfo[playerid][LSPDLEVEL] >= 8)
  {
   new tmp[256], tmp2[256], Index;		
   tmp = strtok(params,Index), 
   tmp2 = strtok(params,Index);
   if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /setlspdlevel [playerid] [level]");
   new player1, level, playername[MAX_PLAYER_NAME], string[128];
   player1 = strval(tmp);
   if(!strlen(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setlspdlevel [playerid] [level]");
   level = strval(tmp2);
   GetPlayerName(player1,playername,sizeof(playername));
  
  format(string,sizeof(string),"You have made %s LSPD Level %d,playername,level);
  SendClientMessage(playerid,red,string);
	PlayerInfo[player1][LSPDLEVEL] = level;
	SendClientMessage(player1,red,"You are now lspd rank %d,level");
  }
  else SendClientMessage(playerid,red,"You are not a lspd CL or HL");

	return 1;
}
Try this and tell me if you get any errors.
Reply
#3

the command has no effect :O
Reply
#4

https://sampwiki.blast.hk/wiki/Fast_Commands
Reply
#5

Quote:
Originally Posted by bartje01
the command has no effect :O
Did you add
Код:
dcmd(setlspdlevel,12,cmdtext);
under OnPlayerCommandText?
Reply
#6

Ah , I had the count on 6, not on 12 xD
I gonna test agin
Reply
#7

ok it is working now but:
When I make someone lvl 4 or something.The one that you make that lvl gets a message like You have been maded lvl 8235873275. xD
Not you have been maded lvl 4

shouldn't this SendClientMessage(player1,red,"You are now lspd rank %d,level");
Be this?SendClientMessage(player1,red,"You are now lspd rank %d",level);
Reply
#8

It should be

pawn Код:
format(string,sizeof(string),"You are now lspd rank %d",level);
SendClientMessage(player1,red,string);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)