Acces Command
#1

hi guys i am using this CMD and i did the [pLevel] thing to use only players lvl 3+ and is didn't working all levels can use this i did all things in enum pinfo etc... with [pLevel] is a FS with DS by IM_BANK the command can be used by rcon admins only and i want to edit only players with lvl 3+

Код HTML:
if(strcmp(cmd, "/acreatecar", true) == 0)
	{
	    if(PlayerInfo[playerid][pLevel] < 4)
     	{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]");
				return 1;
			}
			new car;
			car = strval(tmp);
			if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]");
				return 1;
			}
			new color1;
			color1 = strval(tmp);
			if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]");
				return 1;
			}
			new color2;
			color2 = strval(tmp);
			if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]");
				return 1;
			}
			new value;
			value = strval(tmp);
			new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
            new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
            format(CarInfo[thiscar][cLicense], 32 ,"ForSale");
	        SetVehicleNumberPlate(vehid,CarInfo[thiscar][cLicense]);
			CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
			CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
			CarInfo[thiscar][cValue] = value; CarInfo[thiscar][cLock] = 0; CarInfo[thiscar][paintjob] = -1; LoadComponents(thiscar);
			PutPlayerInVehicle(playerid,thiscar,0);
			strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
			format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
			format(string, sizeof(string), " Masina %d a fost creata cu succes!.", thiscar);
			SendClientMessage(playerid, COLOR_BLUE, string);
		}
		else
		{
		    SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
			return 1;
		}
	}
Quote:

in a short mode: how can i make this command only for players with lvl 3+

Reply
#2

pawn Код:
if(PlayerInfo[playerid][pLevel] < 4)
you are checking if the player is less than level 4, you need to change it to >= 3, for more than or equal to 3/
Reply
#3

now i can't use it at any level
Reply
#4

tbh using strtok now when you have so many much better options seems like a complete waste of time, if I where you I would stop using it

EDIT:
just to show you what this command would look like using dcmd and sscanf:
PHP код:
dcmd_acreatecar(playeridparams[]) {
    if(
PlayerInfo[playerid][pLevel] >= 3) {
        new 
caridculoare1culoare2pretul;
        if(
sscanf(params"iiii"caridculoare1culoare2pretul)) SendClientMessage(playerid, -1"USAGE: /acreatecar [carid] [culoare1] [culoare2] [Pretul]");
        if(
carid >= 400 || carid <= 611) {
            if(
culoare1 >= || culoare1 <= 126 && culoare2 >= || culoare2 <= 126) {
            
                new 
Float:X,Float:Y,Float:ZGetPlayerPos(playeridX,Y,Z);
                new 
thiscar CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
                
format(CarInfo[thiscar][cLicense], 32 ,"ForSale");
                
SetVehicleNumberPlate(vehid,CarInfo[thiscar][cLicense]);
                
CarInfo[thiscar][cOwned] = 0CarInfo[thiscar][cModel] = carCarInfo[thiscar][cColorOne] = color1CarInfo[thiscar][cColorTwo] = color2;
                
CarInfo[thiscar][cLocationx] = XCarInfo[thiscar][cLocationy] = YCarInfo[thiscar][cLocationz] = ZCarInfo[thiscar][cAngle] = 1;
                
CarInfo[thiscar][cValue] = valueCarInfo[thiscar][cLock] = 0CarInfo[thiscar][paintjob] = -1LoadComponents(thiscar);
                
PutPlayerInVehicle(playerid,thiscar,0);
                
strmid(CarInfo[vehid][cOwner], "Dealership"0strlen("Dealership"), 999);
                
format(CarInfo[thiscar][cDescription], 32"%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
                
format(stringsizeof(string), " Masina %d a fost creata cu succes!."thiscar);
                
SendClientMessage(playeridCOLOR_BLUEstring);
                
            }
            else 
SendClientMessage(playeridCOLOR_WHITE" Color Number can't be below 0 or above 126 !");
        }
        else 
SendClientMessage(playeridCOLOR_WHITE" Vehicle Number can't be below 400 or above 611 !");
    }
    else 
SendClientMessage(playeridCOLOR_GRAD1" you are not authorized to use that command!");
    return 
1;

it's much easier to handle the code when it's on a more simplistic level, there are tonnes of sscanf tutorials in the tutorial section.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)