Help Need Help -
RicaNiel - 10.04.2012
i always get this error
even if i try
pawn Код:
Age[playerid] = inputtext;
and this
pawn Код:
pData[playerid][pAge] = inputtext;
Код:
C:\Users\Daniel\SanAndreas Muliplayer\0.3e\gamemodes\ricaniel.pwn(472) : error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Help Need Help -
ReneG - 10.04.2012
inputtext is a string.
You could try converting it to an integer by using strval.
Strval converts an integer into a string.
pawn Код:
pData[playerid][pAge] = strval(inputtext);
If that doesn't work. You need to post more code.
Re: Help Need Help -
RicaNiel - 10.04.2012
It Work Thank You +rep
but anyways
i am lttile confuse about strval - strlen and etc.. can i ask for some information to that?
Re: Help Need Help -
ViniBorn - 10.04.2012
Quote:
Originally Posted by RicaNiel
i am lttile confuse about strval - strlen and etc.. can i ask for some information to that?
|
strval - Convert string to integer
strlen - Check the length
In
https://sampwiki.blast.hk/wiki/Category:Scripting_Functions you can find more functions ...
Re: Help Need Help -
ReneG - 11.04.2012
Strval has one parameter, in that parameter you put the string you want to convert into an integer instead.
pawn Код:
new string[4] = "255"; // This is just made up of characters.
new variable = 255; // This is a number.
So the code below wont work....The string is 255, but it is just a string, not a number.
pawn Код:
GivePlayerMoney(playerid, string);
Instead you would use strval to convert the string into a number.
pawn Код:
new string[4] = "400";
GivePlayerMoney(playerid, strval(string)); // This converts the string into the number 400 and will give the player the money.
Strlen just counts the characters in a string, and returns an integer.
Example.
pawn Код:
new string[11] = "Hello John";
printf("String has %d characters in it.",strlen(string));
Will print
Код:
String has 10 characters in it. Since there are 10 chars in the string.
Hope I helped.
Re: Help Need Help -
RicaNiel - 11.04.2012
Ok for example i want to insert a string using input text
what should i use?\
if i use this "Hello this is my text"
i use that in inputtext
what should i use?
is it strlen?
Re: Help Need Help -
ReneG - 11.04.2012
What do you mean exactly?
What do you want your code to do?
Re: Help Need Help -
RicaNiel - 11.04.2012
this one
pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,D_SEX,INPUT,""CSERVER"RicaNiel Role-Play",""CWHITE"Please Select Your Gender","Proceed","Cancel");
if(strfind(inputtext,"Male",true))
{
new gender[50];
format(gender,sizeof(gender),"%s",inputtext);
pData[playerid][pSex] = gender;
}
}
}
}
still has errors
pawn Код:
C:\Users\Daniel\SanAndreas Muliplayer\0.3e\gamemodes\ricaniel.pwn(486) : error 006: must be assigned to an array
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
Re: Help Need Help -
ReneG - 11.04.2012
You are using strfind incorrectly. You have to see if strfind returns -1 for it to be true. You should use strcmp instead.
Example
pawn Код:
if(!strcmp(inputtext,"America",true))
{
SendClientMessage(playerid, -1, "You typed America in the dialog box!");
return 1;
}
Another flaw in your code is the variable
You need to make sure that that variable is a string in your Player Data enumerator.
I use this stock to replace a string.
pawn Код:
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++) {
if(string[i] == find) {
string[i] = replace;
}
}
}
This is how it is used
pawn Код:
if(!strcmp(inputtext,"Male",true))
{
SendClientMessage(playerid, -1, "So you are a Male!");
strreplace(pData[playerid][pSex],pData[playerid][pSex],inputtext);
// The first parameter gets the string
// The second parameter basically selects the whole string
// The last parameter replaces the whole string with the dialog inputtext.
return 1;
}
Re: Help Need Help -
RicaNiel - 11.04.2012
Oh i get it
thanks