House system problem ? -
Metharon - 10.06.2015
I type here /createhouse and the params
And boom .
WTF?
pawn Код:
if(strcmp(cmd, "/createhouse", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
if(PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GRAD1, "You don't have acces to use this command.");
return 1;
}
new type;
new price;
new level;
new interior;
type = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
price = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
level = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
interior = strval(tmp);
tmp = strtok(cmdtext, idx);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new hid = sHouse + 1;
HouseInfo[hid][hOwned] = 0;
HouseInfo[hid][hRent] = 0;
HouseInfo[hid][hLevel] = level;
HouseInfo[hid][hTakings] = 0;
format(HouseInfo[hid][hOwner], 128, "No-One");
if(type == 1)
{
printf("Type luat");
if(interior == 1)
{
printf("Interior luat");
HouseInfo[hid][hType] = 1;
HouseInfo[hid][hInt] = 10;
HouseInfo[hid][hExitx] = 2259.38;
HouseInfo[hid][hExity] = -1135.77;
HouseInfo[hid][hExitz] = 1050.64;
HouseInfo[hid][hEntrancex] = x;
HouseInfo[hid][hEntrancey] = y;
HouseInfo[hid][hEntrancez] = y;
}
}
new fftext[20];
if(HouseInfo[hid][hType] == 1) { fftext = "mic"; }
HouseInfo[hid][hPickup] = AddStaticPickup(1273, 23, HouseInfo[hid][hEntrancex],HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez]);
format(string, sizeof(string), "[ Casa de vanzare ]\n\n( Pret de cumparare %d$ )\n( Nivelul necesar %d )\n( Interiorul este %s )", HouseInfo[hid][hValue], HouseInfo[hid][hLevel], fftext);
HouseInfo[hid][hText3D] = CreateDynamic3DTextLabel(string, COLOR_GROVE, HouseInfo[hid][hEntrancex],HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez]+0.75,10.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1,0,-1,-1, 45.0);
sHouse++;
printf(" Am creat casa %d", sHouse);
}
return 1;
}
Re: House system problem ? -
Jimmy0wns - 10.06.2015
This should do the job, but please, stop using these damn old methods, this could've be done way faster using the current plugins and includes out there to make it easier.
PHP код:
if(strcmp(cmd, "/createhouse", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
if(PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GRAD1, "You don't have acces to use this command.");
return 1;
}
new type;
new price;
new level;
new interior;
type = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
price = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
level = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
interior = strval(tmp);
tmp = strtok(cmdtext, idx);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new hid = sHouse + 1;
HouseInfo[hid][hOwned] = 0;
HouseInfo[hid][hRent] = 0;
HouseInfo[hid][hLevel] = level;
HouseInfo[hid][hTakings] = 0;
format(HouseInfo[hid][hOwner], 128, "No-One");
if(type == 1)
{
printf("Type luat");
if(interior == 1)
{
printf("Interior luat");
HouseInfo[hid][hType] = 1;
HouseInfo[hid][hInt] = 10;
HouseInfo[hid][hExitx] = 2259.38;
HouseInfo[hid][hExity] = -1135.77;
HouseInfo[hid][hExitz] = 1050.64;
HouseInfo[hid][hEntrancex] = x;
HouseInfo[hid][hEntrancey] = y;
HouseInfo[hid][hEntrancez] = y;
}
}
new fftext[20];
if(HouseInfo[hid][hType] == 1) { fftext = "mic"; }
HouseInfo[hid][hPickup] = AddStaticPickup(1273, 23, HouseInfo[hid][hEntrancex],HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez]);
format(string, sizeof(string), "[ Casa de vanzare ]\n\n( Pret de cumparare %d$ )\n( Nivelul necesar %d )\n( Interiorul este %s )", HouseInfo[hid][hValue], HouseInfo[hid][hLevel], fftext);
HouseInfo[hid][hText3D] = CreateDynamic3DTextLabel(string, COLOR_GROVE, HouseInfo[hid][hEntrancex],HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez],10.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1,0,-1,-1, 45.0);
sHouse++;
printf(" Am creat casa %d", sHouse);
}
return 1;
}
Re: House system problem ? -
CodeStyle175 - 10.06.2015
PHP код:
if(strcmp(cmd, "/createhouse", true) == 0)
{
//You don't need to check if player is connected ...
if(PlayerInfo[playerid][pAdmin] < 3)return SendClientMessage(playerid, COLOR_GRAD1, "You don't have acces to use this command.");
new type,price,level,interior;
if(sscanf(cmd, "dddd", type,price,level,interior)){
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createhouse [type] [price] [level] [interior]");
SendClientMessage(playerid, COLOR_GRAD2, "TYPE: (1) Small , Medium , Big");
return 1;
}
GetPlayerPos(playerid, HouseInfo[hid][hEntrancex], HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez]);
new hid = sHouse + 1;
HouseInfo[hid][hOwned] = 0;
HouseInfo[hid][hRent] = 0;
HouseInfo[hid][hLevel] = level;
HouseInfo[hid][hTakings] = 0;
format(HouseInfo[hid][hOwner], 24, "No-One");//MAX name length 24
if(type == 1){
if(interior == 1){
HouseInfo[hid][hType] = 1;
HouseInfo[hid][hInt] = 10;
HouseInfo[hid][hExitx] = 2259.38;
HouseInfo[hid][hExity] = -1135.77;
HouseInfo[hid][hExitz] = 1050.64;
}
}
new fftext[20];
if(HouseInfo[hid][hType] == 1) { fftext = "mic"; }
HouseInfo[hid][hPickup] = AddStaticPickup(1273, 23, HouseInfo[hid][hEntrancex],HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez]);
format(string, sizeof(string), "[ Casa de vanzare ]\n\n( Pret de cumparare %d$ )\n( Nivelul necesar %d )\n( Interiorul este %s )", HouseInfo[hid][hValue], HouseInfo[hid][hLevel], fftext);
HouseInfo[hid][hText3D] = CreateDynamic3DTextLabel(string, COLOR_GROVE, HouseInfo[hid][hEntrancex],HouseInfo[hid][hEntrancey], HouseInfo[hid][hEntrancez],10.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1,0,-1,-1, 45.0);
sHouse++;
printf(" Am creat casa %d", sHouse);
return 1;
}