03.02.2016, 08:47
Код:
CMD:set(playerid,params[]){ if(sscanf(params,"usi",param[0],String,param[1])) return MSG(playerid,C_RED,"/Set [ID] [Database] [Amount]"); DB[param[0]][String] = param[1]; return 1;}
CMD:set(playerid,params[]){ if(sscanf(params,"usi",param[0],String,param[1])) return MSG(playerid,C_RED,"/Set [ID] [Database] [Amount]"); DB[param[0]][String] = param[1]; return 1;}
new String[128]; // <- let's assume that the sizeof the string is 128.
if(sscanf(params,"us[128]i",param[0],String,param[1])) return MSG(playerid,C_RED,"/Set [ID] [Database] [Amount]"); // we added the '[128]' beside the string prefix 's' as you can see, which is the length of 'String' variable.
str[128],
format(DB[params[0]][str], 128, String);
new id, a;
if(sscanf(params,"us[128]i",id,String,a)) return MSG(playerid,C_RED,"/Set [ID] [Database] [Amount]");
format(DB[id][str], 128, String);
if(!strcmp(string,"Money"))
{
//Set his money bla bla bla
}
you can't replace a constant enum variable with a randomly created variable,
and this is not the proper way to assign a value to a string variable firstly, i guess you want to create a string variable in the command, so simply: pawn Код:
pawn Код:
pawn Код:
pawn Код:
- it would be better to create variable for each parameter, i.e, instead of that params[0] and params[1], just add 'id' variable, and a variable for amount, let's call it 'a', and the changes done are: pawn Код:
|
This is happening because you are miss-understanding what enum is, You can think of enum as constant variables that will be replaced by numbers at compile time, so a Money in enum is not a string, but rather a number (for example 6th element in an array), so "Money" as string is not equal to Money of an enum, what you can do is however making a switch
PHP код:
|
where do you get the first error "error 033: array must be indexed (variable "str") "? copy the line and paste it here
|
CMD:setint(playerid,params[]){ new id, a, str[128]; if(sscanf(params,"us[128]i",id,String,a)) return MSG(playerid,C_RED,"/Set [ID] [Database] [Amount]"); format(DB[id][str], 128, String); return 1;}