Question about createprop.
#1

Hi
I have a question, i am busy with a property include and I made that with someone else, he had mysql, me not.
The problem is: When I do /createprop (interior ID) so for example /createprop 40
Then he only recognise /createprop the space between he doenst see.
In the sa-mp: Server, the black screen it says:
Returns string: 50 Value: 0

Can someone please help me that I can fix this?

Sorry for my not so good english

if(CompareString("/createprop",cmdtext))
{
if(!IsPlayerAdmin(playerid))
{//berichtje je hebt geen recht tot deze command
return SendClientMessage(playerid,COLOR_USAGE,"You are not allowed to use this command!");
}
cmdstring[0][1]=1;// kijk dit bedoel, in dat zwarte scherm komt er bij /createprop 50 te staan: returns string: 50 value: 0hmm iS DIt alles? of nog meer van /createprop is dit allesDan kan ik jou nu vertelle dat dit niet kan.
new realvalue;
realvalue=strval(strtok(cmdtext,cmdstring[0][1]));//
printf("returns string: %s value: %d",strtok(cmdtext,cmdstring[0][1]),realvalue);
if(realvalue<0 || realvalue>=sizeof(Property_Coordinates))
{
SendClientMessage(playerid,COLOR_USAGE,"/createprop [InteriorID]");
//berichtje verkeerde interieur ID opgegeven
}
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
if(CreateProperty(X,Y,Z,realvalue))
{
SendClientMessage(playerid,COLOR_WHITE,"Created!") ;
//message property created
}else
{
SendClientMessage(playerid,COLOR_WHITE,"Failed!");
//message property failed to create
}
return 1;
}
Reply
#2

You haven't split cmdtext[] into a string or int you can use
Reply
#3

Quote:
Originally Posted by TheInnocentOne
You haven't split cmdtext[] into a string or int you can use
So how I do that?
Reply
#4

assuming that the black screen is the server (control),
The information given from the strtok is really returned.

/createprop 50,
then in the screen it says it got 50 in string value, but 0 in integer value.

Meaning either the strval function is fucked or there are unwanted characters in the string.
In that case, you gotta remove the unwanted characters.

But the main question is, how did it got there?

My guess is, that there is a space inside the returned string, returning " 50" in total.
This would mean the function strval doesn't work and returns zero because of the space.

That would be removing the space in order to solve this issue.
1. Replace the strtok with a working one.
2. Use strmid to extract everything but the first character.
Reply
#5

Quote:
Originally Posted by maij
assuming that the black screen is the server (control),
The information given from the strtok is really returned.

/createprop 50,
then in the screen it says it got 50 in string value, but 0 in integer value.

Meaning either the strval function is fucked or there are unwanted characters in the string.
In that case, you gotta remove the unwanted characters.

But the main question is, how did it got there?

My guess is, that there is a space inside the returned string, returning " 50" in total.
This would mean the function strval doesn't work and returns zero because of the space.

That would be removing the space in order to solve this issue.
1. Replace the strtok with a working one.
2. Use strmid to extract everything but the first character.
I use now sscanf and it is solver thanks for help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)