strcmp to zcmd sscanf
#1

Hi, im using Cali cars and i placed it in my GM in which i use zcmd and sscanf.
So i need to change it from strcmp to zcmd sscanf. I managed to change all commands except this one. Can't understand how to change this one
help pls
Код:
    new idx, tmp[128], cmd[128];
	cmd = strtok(cmdtext, idx);
	if(strcmp(cmd, "/trunk", true) == 0)
	{
	    if(gPlayerHasCar[playerid] == 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  You don't own a car !");
	    new x_nr[256];
		x_nr = strtok(cmdtext, idx);
		if(!strlen(x_nr))
	    {
			SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /trunk [item]");
			SendClientMessage(playerid, 0xFFFFFFFF, "Available items: open, close, check, putgun, takegun");
			return 1;
  		}
  		if(strcmp(x_nr, "open", true) == 0)
  		{
			if(TrunkOpen[Vehicle[playerid]] == 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  The trunk is already open !");
			new engine, lights, alarm, doors, bonnet, boot, objective;
	        GetVehicleParamsEx(Vehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(Vehicle[playerid], engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
            TrunkOpen[Vehicle[playerid]] = 1;
			return 1;
		}
		if(strcmp(x_nr, "close", true) == 0)
  		{
  		    if(TrunkOpen[Vehicle[playerid]] == 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  The trunk is already closed !");
			new engine, lights, alarm, doors, bonnet, boot, objective;
	        GetVehicleParamsEx(Vehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(Vehicle[playerid], engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective);
            TrunkOpen[Vehicle[playerid]] = 0;
			return 1;
		}
		if(strcmp(x_nr, "putgun", true) == 0)
		{
		    if(TrunkOpen[Vehicle[playerid]] == 0) { SendClientMessage(playerid, 0xAFAFAFAA, "  You must open the trunk first !"); return 1; }
		    tmp = strtok(cmdtext, idx);
			if(!strlen(tmp)) { SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /trunk putgun [slot]"); return 1; }
			new slot = strval(tmp), weapon = GetPlayerWeapon(playerid);
			if(slot < 1 || slot > 10) { SendClientMessage(playerid, 0xAFAFAFAA, "   Slot can't be below 1 or above 10 !"); return 1; }
			if(weapon == 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  You don't have a weapon !");
			if(slot == 1)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot1] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot1] = weapon;
			    TrunkInfo[v][Ammo1] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 1 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 2)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot2] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot2] = weapon;
			    TrunkInfo[v][Ammo2] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 2 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 3)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot3] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot3] = weapon;
			    TrunkInfo[v][Ammo3] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 3 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 4)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot4] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot4] = weapon;
			    TrunkInfo[v][Ammo4] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 4 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
			if(slot == 5)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot5] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot5] = weapon;
			    TrunkInfo[v][Ammo5] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 5 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 6)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot6] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot6] = weapon;
			    TrunkInfo[v][Ammo6] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 6 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
			if(slot == 7)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot7] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot7] = weapon;
			    TrunkInfo[v][Ammo7] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 7 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 8)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot8] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot8] = weapon;
			    TrunkInfo[v][Ammo8] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 8 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 9)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot9] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot9] = weapon;
			    TrunkInfo[v][Ammo9] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 9 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
   			if(slot == 10)
			{
			    new string[128], gunname[16];
			    new ammo = GetPlayerAmmo(playerid);
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot10] > 0) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is already something there !");
			    TrunkInfo[v][Slot10] = weapon;
			    TrunkInfo[v][Ammo10] = ammo;
			    GetWeaponName(weapon, gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have stored your %s into slot 10 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    RemovePlayerWeapon(playerid, weapon);
			    return 1;
   			}
		}
		if(strcmp(x_nr, "takegun", true) == 0)
		{
      		if(TrunkOpen[Vehicle[playerid]] == 0) { SendClientMessage(playerid, 0xAFAFAFAA, "  You must open the trunk first !"); return 1; }
		    tmp = strtok(cmdtext, idx);
			if(!strlen(tmp)) { SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /trunk takegun [slot]"); return 1; }
			new slot = strval(tmp);
			if(slot < 1 || slot > 10) { SendClientMessage(playerid, 0xAFAFAFAA, "   Slot can't be below 1 or above 10 !"); return 1; }
			if(slot == 1)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot1] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot1], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 1 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot1], TrunkInfo[v][Ammo1]);
			    TrunkInfo[v][Slot1] = 0;
			    TrunkInfo[v][Ammo1] = 0;
			    return 1;
    		}
    		if(slot == 2)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot2] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot2], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 2 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot2], TrunkInfo[v][Ammo2]);
			    TrunkInfo[v][Slot2] = 0;
			    TrunkInfo[v][Ammo2] = 0;
			    return 1;
    		}
    		if(slot == 3)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot3] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot3], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 3 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot3], TrunkInfo[v][Ammo3]);
			    TrunkInfo[v][Slot3] = 0;
			    TrunkInfo[v][Ammo3] = 0;
			    return 1;
    		}
    		if(slot == 4)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot4] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot4], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 4 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot4], TrunkInfo[v][Ammo4]);
			    TrunkInfo[v][Slot4] = 0;
			    TrunkInfo[v][Ammo4] = 0;
			    return 1;
    		}
    		if(slot == 5)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot5] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot5], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 5 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot5], TrunkInfo[v][Ammo5]);
			    TrunkInfo[v][Slot5] = 0;
			    TrunkInfo[v][Ammo5] = 0;
			    return 1;
    		}
    		if(slot == 6)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot6] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot6], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 6 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot6], TrunkInfo[v][Ammo6]);
			    TrunkInfo[v][Slot6] = 0;
			    TrunkInfo[v][Ammo6] = 0;
			    return 1;
    		}
    		if(slot == 7)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot7] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot7], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 7 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot7], TrunkInfo[v][Ammo7]);
			    TrunkInfo[v][Slot7] = 0;
			    TrunkInfo[v][Ammo7] = 0;
			    return 1;
    		}
    		if(slot == 8)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot8] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot8], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 8 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot8], TrunkInfo[v][Ammo8]);
			    TrunkInfo[v][Slot8] = 0;
			    TrunkInfo[v][Ammo8] = 0;
			    return 1;
    		}
    		if(slot == 9)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot9] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot9], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 9 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot9], TrunkInfo[v][Ammo9]);
			    TrunkInfo[v][Slot9] = 0;
			    TrunkInfo[v][Ammo9] = 0;
			    return 1;
    		}
    		if(slot == 10)
			{
				new string[128], gunname[16];
			    new v = Vehicle[playerid];
			    if(TrunkInfo[v][Slot10] < 1) return SendClientMessage(playerid, 0xAFAFAFAA, "  There is nothing there !");
			    GetWeaponName(TrunkInfo[v][Slot10], gunname, sizeof(gunname));
			    format(string, sizeof(string), "You have taken your %s from slot 10 of your trunk.",gunname);
			    SendClientMessage(playerid, 0xFFFF00FF, string);
			    GivePlayerWeapon(playerid, TrunkInfo[v][Slot10], TrunkInfo[v][Ammo10]);
			    TrunkInfo[v][Slot10] = 0;
			    TrunkInfo[v][Ammo10] = 0;
			    return 1;
			}
    	}
    	if(strcmp(x_nr, "check", true) == 0)
		{
		    new gunname[16], gunname2[16], gunname3[16], gunname4[16], gunname5[16], gunname6[16], gunname7[16], gunname8[16], gunname9[16],
			gunname10[16], string[64], string2[64], string3[64], string4[64], string5[64], string6[64], string7[64], string8[64], string9[64], string10[64];
		    if(TrunkOpen[Vehicle[playerid]] == 0) { SendClientMessage(playerid, 0xAFAFAFAA, "  You must open the trunk first !"); return 1; }
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot1], gunname, sizeof(gunname));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot2], gunname2, sizeof(gunname2));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot3], gunname3, sizeof(gunname3));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot4], gunname4, sizeof(gunname4));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot5], gunname5, sizeof(gunname5));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot6], gunname6, sizeof(gunname6));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot7], gunname7, sizeof(gunname7));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot8], gunname8, sizeof(gunname8));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot9], gunname9, sizeof(gunname9));
			GetWeaponName(TrunkInfo[Vehicle[playerid]][Slot10], gunname10, sizeof(gunname10));
			SendClientMessage(playerid, 0x33AA33AA, "___________________________");
			if(TrunkInfo[Vehicle[playerid]][Slot1] != 0) { format(string, sizeof(string), "Slot 1: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo1]); } else { format(string, sizeof(string), "Slot 1: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot2] != 0) { format(string, sizeof(string), "Slot 2: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo2]); } else { format(string, sizeof(string), "Slot 2: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot3] != 0) { format(string, sizeof(string), "Slot 3: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo3]); } else { format(string, sizeof(string), "Slot 3: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot4] != 0) { format(string, sizeof(string), "Slot 4: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo4]); } else { format(string, sizeof(string), "Slot 4: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot5] != 0) { format(string, sizeof(string), "Slot 5: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo5]); } else { format(string, sizeof(string), "Slot 5: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot6] != 0) { format(string, sizeof(string), "Slot 6: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo6]); } else { format(string, sizeof(string), "Slot 6: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot7] != 0) { format(string, sizeof(string), "Slot 7: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo7]); } else { format(string, sizeof(string), "Slot 7: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot8] != 0) { format(string, sizeof(string), "Slot 8: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo8]); } else { format(string, sizeof(string), "Slot 8: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot9] != 0) { format(string, sizeof(string), "Slot 9: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo9]); } else { format(string, sizeof(string), "Slot 9: None (0 Ammo)"); }
			if(TrunkInfo[Vehicle[playerid]][Slot10] != 0) { format(string, sizeof(string), "Slot 10: %s (%i Ammo)", gunname, TrunkInfo[Vehicle[playerid]][Ammo10]); } else { format(string, sizeof(string), "Slot 10: None (0 Ammo)"); }
		    SendClientMessage(playerid, 0xFFFFFFFF, string);
		    SendClientMessage(playerid, 0xFFFFFFFF, string2);
		    SendClientMessage(playerid, 0xFFFFFFFF, string3);
		    SendClientMessage(playerid, 0xFFFFFFFF, string4);
		    SendClientMessage(playerid, 0xFFFFFFFF, string5);
		    SendClientMessage(playerid, 0xFFFFFFFF, string6);
		    SendClientMessage(playerid, 0xFFFFFFFF, string7);
		    SendClientMessage(playerid, 0xFFFFFFFF, string8);
		    SendClientMessage(playerid, 0xFFFFFFFF, string9);
		    SendClientMessage(playerid, 0xFFFFFFFF, string10);
		    SendClientMessage(playerid, 0x33AA33AA, "___________________________");
		    return 1;
		}
	    return 1;
 	}
Reply
#2

https://sampwiki.blast.hk/wiki/Fast_Commands#zcmd
Reply
#3

Well.... I was trying to do it using tuts and wiki fo awhile(3hours).
But i failed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)