Little help please - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Little help please (
/showthread.php?tid=209522)
Little help please -
bartje01 - 10.01.2011
Hey guys.
How to make this like you can do /fheal armor
Because this give errors at this part:P
if(choice[playerid] == "health")
I'm out of mind once again
please help
pawn Код:
COMMAND:fheal(playerid,params[])
{
new choice;
if(funpoints[playerid]<8) return SendClientMessage(playerid, COLOR_DARKORANGE, "You need atleast 8 funpoints");
if(sscanf(params,"s",choice)) SendClientMessage(playerid, COLOR_DARKORANGE, "HINT: /fheal [health/armor]");
else
{
if(choice[playerid] == "health")
{
}
}
return 1;
}
Код:
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : error 028: invalid subscript (not an array or too many subscripts): "choice"
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : warning 215: expression has no effect
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : error 001: expected token: ";", but found "]"
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : error 029: invalid expression, assumed zero
C:\Users\Michael\Desktop\Samp scvripting\filterscripts\funpoints.pwn(189) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Little help please -
Outcast - 10.01.2011
choice has to be a string
Before the hint message (SendClientM....) you need to put return, like above (not sure about this one)
also, in sscanf where there's "s" you need to put "s[10]".
I hope I help
Re: Little help please -
JaTochNietDan - 10.01.2011
Okay there's a few problems with your command, please read the comments in this fixed code:
pawn Код:
COMMAND:fheal(playerid,params[])
{
new choice[20]; // You need to initialize it as an array, as it requires multiple cells to hold each character in the string
if(funpoints[playerid]<8) return SendClientMessage(playerid, COLOR_DARKORANGE, "You need atleast 8 funpoints");
if(sscanf(params,"s",choice)) SendClientMessage(playerid, COLOR_DARKORANGE, "HINT: /fheal [health/armor]");
else
{
if(!strcmp(choice,"health",true)) // Pawn does not allow direct comparisons of strings, you must use the strcmp function
{
}
}
return 1;
}
Re: Little help please -
bartje01 - 10.01.2011
Ah guys. Now I remember it again.
Thankyou so much.
I started scripting again since a week so. I have to get warmed up again :P