command doesnt work good (+rep for helper) -
GTAItsMe - 20.11.2012
the command:
PHP код:
CMD:function(playerid, params[])
{
new function, parameters[5], str[128];
if(sscanf(params, "sp< >a<s>(-1)[5]", function, parameters))return SendClientMessage(playerid, 0xFF000000, "SYNTAX: /function <function> <Prameters...>");
else{
for(new i; i < sizeof(parameters); ++i)
{
format(str, 128, "%s", function);
CallLocalFunction(str, "s", parameters[i]);
}
}
return 1;
}
Re: command doesnt work good (+rep for helper) -
vernz - 20.11.2012
Explain your problem .. what are those <> where your parameters are ?
Re: command doesnt work good (+rep for helper) -
GTAItsMe - 20.11.2012
Quote:
Originally Posted by vernz
Explain your problem .. what are those <> where your parameters are ?
|
the command need to create function in the server, the <> are for the split..
after i do like:
PHP код:
/function SendClientMessage 0 0xFF000000 "Hello"
i get message command not exists...
but when i stay it null:
i get the error:
PHP код:
SYNTAX: /function <function> <Prameters...>
Re: command doesnt work good (+rep for helper) -
vernz - 20.11.2012
Just gimme an example of this command /function then ?
Re: command doesnt work good (+rep for helper) -
GTAItsMe - 20.11.2012
Quote:
Originally Posted by vernz
Just gimme an example of this command /function then ?
|
PHP код:
/function SendClientMessage 0 0xFF000000 "Hello"
Re: command doesnt work good (+rep for helper) -
park4bmx - 20.11.2012
did you do any debugging before you come here ?
you probably get Unknown Command because
CallLocalFunction doesn't find the function you typed and returns:0
Edit
CallLocalFunction needs to be outside the loop.
Now becosue there are multiple parameters
you will need
strcat inside the loop to combine them. and then add them to the
CallLocalFunction (outside the loop)
edit 2
look at ryders in game compiler
https://sampforum.blast.hk/showthread.php?tid=252372
But it actually compiles the code by using a .dll to execute into pawncc
its a lot more complicated then this.
Re: command doesnt work good (+rep for helper) -
GTAItsMe - 20.11.2012
Quote:
Originally Posted by park4bmx
did you do any debugging before you come here ?
you probably get Unknown Command because CallLocalFunction doesn't find the function you typed and returns:0
Edit
CallLocalFunction needs to be outside the loop.
Now becosue there are multiple parameters
you will need strcat inside the loop to combine them. and then add them to the CallLocalFunction (outside the loop)
edit 2
look at ryders in game compiler
https://sampforum.blast.hk/showthread.php?tid=252372
But it actually compiles the code by using a .dll to execute into pawncc
its a lot more complicated then this.
|
you think its gonna work?
PHP код:
CMD:function(playerid, params[])
{
new function, parameters[5], str[128], para;
if(sscanf(params, "sp< >a<s>(-1)[5]", function, parameters))return SendClientMessage(playerid, 0xFF000000, "SYNTAX: /function <function> <Prameters...>");
else{
for(new i; i < sizeof(parameters); ++i)
{
para = parameters[i];
}
format(str, 128, "%s", function);
CallLocalFunction(str, "s", para);
}
return 1;
}
Re: command doesnt work good (+rep for helper) -
park4bmx - 20.11.2012
not really.
i was talking about something like this
pawn Код:
new AStr[240],FStr[240];
for(new i; i < sizeof(parameters); ++i)
{
format(AStr, sizeof(AStr),"%s,", function);
strcat(FStr, AStr, sizeof(FStr));
}
CallLocalFunction(FStr, "ssss", parameters[0],parameters[1],parameters[2],parameters[3]);
something like this, but i don't think it will work because like i said
CallLocalFunction is used to
call not to make new functions.
Re: command doesnt work good (+rep for helper) -
GTAItsMe - 21.11.2012
Quote:
Originally Posted by park4bmx
not really.
i was talking about something like this
pawn Код:
new AStr[240],FStr[240]; for(new i; i < sizeof(parameters); ++i) { format(AStr, sizeof(AStr),"%s,", function); strcat(FStr, AStr, sizeof(FStr)); } CallLocalFunction(FStr, "ssss", parameters[0],parameters[1],parameters[2],parameters[3]);
something like this, but i don't think it will work because like i said CallLocalFunction is used to call not to make new functions.
|
i think its not the best solution and i dont want to create new function, i want to call to exists function..
more?
Re: command doesnt work good (+rep for helper) -
GTAItsMe - 21.11.2012
someone?