Command partly isn't working -
dusk - 02.03.2013
I was creating a house system. So this command should create a house:
pawn Код:
CMD:createhouse(playerid,params[])
{
new HousePrice,tmp=HouseCount;
if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid,0xFF0000FF,"Tu negali naudot sitos komandos,lops");
else if(sscanf(params,"d",HousePrice)) SendClientMessage(playerid,0xFF0000FF,"Naudojimas /createhouse [Namo Kaina]");
else
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
HouseInfo[tmp][Price]=HousePrice;
HouseInfo[tmp][Owned]=0;
HouseInfo[tmp][PosX]=x;
HouseInfo[tmp][PosY]=y;
HouseInfo[tmp][PosZ]=z;
HouseInfo[tmp][VirtualWorld] = GetPlayerVirtualWorld(playerid);
HouseEnter[tmp]=CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));
format(HouseInfo[tmp][Owner],24,"None");
HouseExit[tmp]=CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));
new query[128],labelstring[126];
format(query,sizeof(query),"INSERT INTO houses (Owner,Owned,VirtualWorld,PosX,PosY,PosZ,Price) VALUES ('%s',0,%d,%f,%f,%f,%s)",HouseInfo[tmp][Owner],GetPlayerVirtualWorld(playerid),x,y,z,HousePrice);
mysql_query(query);
format(labelstring,sizeof(labelstring),"Namas Parduodamas \n Kaina:%d \nNoredamas pirkti rasyk /buyhouse",HousePrice);
HouseInfo[tmp][HouseLabel] = Create3DTextLabel(labelstring,0x00FF00FF,x,y,z,25,GetPlayerVirtualWorld(playerid),0);
HouseCount++;
}
return 1;
}
But the thing is, if I use /createhouse, it works,it sends the text.But if I use it correctly, /creathouse 1000, I get: Server:Unknown command. Like wtf?
Re: Command partly isn't working -
Djole1337 - 02.03.2013
You don't need else.
pawn Код:
CMD:createhouse(playerid,params[])
{
new HousePrice,tmp=HouseCount;
if(!IsPlayerAdmin(playerid)) SendClientMessage(playerid,0xFF0000FF,"Tu negali naudot sitos komandos,lops");
if(sscanf(params,"d",HousePrice)) SendClientMessage(playerid,0xFF0000FF,"Naudojimas /createhouse [Namo Kaina]");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
HouseInfo[tmp][Price]=HousePrice;
HouseInfo[tmp][Owned]=0;
HouseInfo[tmp][PosX]=x;
HouseInfo[tmp][PosY]=y;
HouseInfo[tmp][PosZ]=z;
HouseInfo[tmp][VirtualWorld] = GetPlayerVirtualWorld(playerid);
HouseEnter[tmp]=CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));
format(HouseInfo[tmp][Owner],24,"None");
HouseExit[tmp]=CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));
new query[128],labelstring[126];
format(query,sizeof(query),"INSERT INTO houses (Owner,Owned,VirtualWorld,PosX,PosY,PosZ,Price) VALUES ('%s',0,%d,%f,%f,%f,%s)",HouseInfo[tmp][Owner],GetPlayerVirtualWorld(playerid),x,y,z,HousePrice);
mysql_query(query);
format(labelstring,sizeof(labelstring),"Namas Parduodamas \n Kaina:%d \nNoredamas pirkti rasyk /buyhouse",HousePrice);
HouseInfo[tmp][HouseLabel] = Create3DTextLabel(labelstring,0x00FF00FF,x,y,z,25,GetPlayerVirtualWorld(playerid),0);
HouseCount++;
return 1;
}
Re: Command partly isn't working -
dusk - 02.03.2013
Still,the same server:unknown command
Re: Command partly isn't working -
dusk - 02.03.2013
bump
Re: Command partly isn't working -
Catalyst- - 02.03.2013
I'm guessing that the "tmp" variable is set to a value that is higher than the size of the array "HouseInfo".
Re: Command partly isn't working -
dusk - 02.03.2013
What do you mean? I was following this tutorial
https://sampforum.blast.hk/showthread.php?tid=287541
House info=new HouseInfo[MAX_HOUSES][hInfo]
Re: Command partly isn't working -
dusk - 02.03.2013
anyone?
Re: Command partly isn't working -
Ruben_Alonso - 02.03.2013
Try this
pawn Код:
CMD:createhouse(playerid,params[])
{
new HousePrice,tmp=HouseCount;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Tu negali naudot sitos komandos,lops");
else if(sscanf(params,"d",HousePrice)) return SendClientMessage(playerid,0xFF0000FF,"Naudojimas /createhouse [Namo Kaina]");
else
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
HouseInfo[tmp][Price]=HousePrice;
HouseInfo[tmp][Owned]=0;
HouseInfo[tmp][PosX]=x;
HouseInfo[tmp][PosY]=y;
HouseInfo[tmp][PosZ]=z;
HouseInfo[tmp][VirtualWorld] = GetPlayerVirtualWorld(playerid);
HouseEnter[tmp]=CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));
format(HouseInfo[tmp][Owner],24,"None");
HouseExit[tmp]=CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));
new query[128],labelstring[256];
format(query,sizeof(query),"INSERT INTO houses (Owner,Owned,VirtualWorld,PosX,PosY,PosZ,Price) VALUES ('%s',0,%d,%f,%f,%f,%s)",HouseInfo[tmp][Owner],GetPlayerVirtualWorld(playerid),x,y,z,HousePrice);
mysql_query(query);
format(labelstring,sizeof(labelstring),"Namas Parduodamas \n Kaina:%d \nNoredamas pirkti rasyk /buyhouse",HousePrice);
HouseInfo[tmp][HouseLabel] = Create3DTextLabel(labelstring,0x00FF00FF,x,y,z,25,GetPlayerVirtualWorld(playerid),0);
HouseCount++;
}
return 1;
}
Re: Command partly isn't working -
dusk - 02.03.2013
Still the same error
Re: Command partly isn't working -
Catalyst- - 02.03.2013
Replace your command with the one below, try it in-game and you'll receive a message in white.
If the value next to "tmp" is higher than the value next to "max_houses", find "#define MAX_HOUSES" in your script and change the value of it to something higher than the one next to "tmp".
pawn Код:
CMD:createhouse(playerid,params[])
{
new str[128];
format(str,sizeof(str),"tmp: %i -- max_houses: %i", HouseCount, MAX_HOUSES);
SendClientMessage(playerid, 0xFFFFFFFF, str);
new HousePrice, tmp=HouseCount;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Tu negali naudot sitos komandos,lops");
if(sscanf(params,"d",HousePrice)) return SendClientMessage(playerid,0xFF0000FF,"Naudojimas /createhouse [Namo Kaina]");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
HouseInfo[tmp][Price]=HousePrice;
HouseInfo[tmp][Owned]=0;
HouseInfo[tmp][PosX]=x;
HouseInfo[tmp][PosY]=y;
HouseInfo[tmp][PosZ]=z;
HouseInfo[tmp][VirtualWorld] = GetPlayerVirtualWorld(playerid);
HouseEnter[tmp]=CreateDynamicCP(x,y,z,1.5,GetPlayerVirtualWorld(playerid));
format(HouseInfo[tmp][Owner],24,"None");
HouseExit[tmp]=CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));
new query[128], labelstring[126];
format(query,sizeof(query),"INSERT INTO houses (Owner,Owned,VirtualWorld,PosX,PosY,PosZ,Price) VALUES ('%s',0,%d,%f,%f,%f,%s)",HouseInfo[tmp][Owner],GetPlayerVirtualWorld(playerid),x,y,z,HousePrice);
mysql_query(query);
format(labelstring,sizeof(labelstring),"Namas Parduodamas \n Kaina:%d \nNoredamas pirkti rasyk /buyhouse",HousePrice);
HouseInfo[tmp][HouseLabel] = Create3DTextLabel(labelstring,0x00FF00FF,x,y,z,25,GetPlayerVirtualWorld(playerid),0);
HouseCount++;
return 1;
}