Help with errors and a question
#1

Ok im trying to make this event system but i want to set it so when the admin sets the weapon they can either enter the weapon id or the name so this is my coding
PHP код:
  new weapid,wname[50],wep,weap;
            if(
sscanf(params, "s[8]ii", option, wep, weap)) return SendClientMessage(playerid, error, "Usage: /eedit weapon [slot] [weaponid]");
            if(
wep < 1 || wep > 3) return SendClientMessage(playerid, error, "Weapon slots are between 1 and 3.");
            if(
IsNumeric(weap)) weapid = strval(weap); // this line has an error
            
else weapid = GetWeaponID(weap);// and this line as well has an error
            
if(weap < 1 || weap > 46) return SendClientMessage(playerid, error, "Invalid weapon ID/Name between [1-46]");
              
GetWeaponName(weapid, wname, sizeof(wname));
            switch(
wep)
            {
                case 
1: EventWep[0] = weapid;
                case 
2: EventWep[1] = weapid;
                case 
3: EventWep[2] = weapid;
            }
            
format(string, sizeof(string), " You have set weapon slot %d to %s.", wep, wname);
            
SendClientMessage(playerid, -1, string);
        } 
But i keep getting errors on two lines...

PHP код:
C:\Users\Andre'\Desktop\Andre'\samp\gamemodes\ODA.pwn(4247) : error 035: argument type mismatch (argument 1)
C:\Users\Andre'\Desktop\Andre'\samp\gamemodes\ODA.pwn(4247) : error 035: argument type mismatch (argument 1)
C:\Users\Andre'\Desktop\Andre'\samp\gamemodes\ODA.pwn(4248) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase
3 Errors
. 
Also could someone show me how to read a specific line with y_ini?
Reply
#2

There's a custom specifier already for weapons in sscanf (latest), use 'k<weapon>'.
Код:
new wname[50],wep,weap; 
if(sscanf(params, "s[8]ik<weapon>", option, wep, weap)) 
	return SendClientMessage(playerid, error, "Usage: /eedit weapon [slot] [weaponid]"); 
if(wep < 1 || wep > 3)
	return SendClientMessage(playerid, error, "Weapon slots are between 1 and 3."); 

if(weap < 1 || weap > 46)
	return SendClientMessage(playerid, error, "Invalid weapon ID/Name between [1-46]"); 

GetWeaponName(weap, wname, sizeof(wname)); 
EventWep[wep - 1] = weap;
format(string, sizeof(string), " You have set weapon slot %d to %s.", wep, wname); 
SendClientMessage(playerid, -1, string);
https://sampforum.blast.hk/showthread.php?tid=570927
Reply
#3

Weap is already an integer. Strval converts 'string' to integer. So that line does'nt make sense. You can delete it.
And in the other line, you used a function that gets weapon's name from a string. But you used an integer variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)