Hello guys.
I have a problem with a command on my server when i use this command /comprarcarro ( /buycar ) command does nothing
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[128];
if (strcmp(cmdtext, "/comprarcarro", true) == 0)
{
new VehicleID;
VehicleID = GetPlayerVehicleID(playerid);
new pname[MAX_PLAYER_NAME];
new aname[MAX_PLAYER_NAME];
new file[128];
GetPlayerName(playerid, aname, sizeof(aname));
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "Contas/%s.ini", aname);
for (new carro = 0; carro < MAX_VEHICLES; carro++)
{
format(string, sizeof(string), "carro%d.ini", carro);
if (strfind(pname,dini_Get(string,"Dono"),true) == 0)
{
SendClientMessage(playerid, -1, "Vocк jб tem um carro");
return 1;
}
if (IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0 && VehicleID == dini_Int(string, "Id"))
{
if (dini_Int(string, "TDono") == 1) return SendClientMessage(playerid, -1, "Esse Carro jб tem dono!");
if (GetPlayerMoney(playerid) >= dini_Int(string, "Preco"))
{
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
dini_IntSet(string, "TDono", 1);
dini_Set(string, "Dono", aname);
SendClientMessage(playerid, -1, "(INFO) Veiculo comprado com sucesso!");
SendClientMessage(playerid, -1, "(INFO) Para ver os comandos do veiculo, use: /meucarro");
GivePlayerMoney(playerid, -dini_Int(string, "Preco"));
TogglePlayerControllable(playerid, 3);
return 1;
} else {
SendClientMessage(playerid, -1, "(ERRO) Vocк nгo tem dinheiro suficiente!");
return 1;
}
}
}
return 1;
}
return 0;
}
Well for one, TogglePlayerControllable(playerid, 3); 3 is not an option, it's either 0 or 1.
The codes says that you need to be in a car on driver side in order to buy a car. Are you sure you are inside that vehicle?
No such thing such as TogglePlayerControllable 3. It's 0 for freezing the player and 1 for unfreezing the player and I see IsPlayerInVehicle, so you must be inside a vehicle.
Yes, but you've got to be inside the vehicle too. Are you sure you're inside an vehicle & you're it's driver?
i puted TogglePlayerControllable 1 and i was in vehicle and im the driver and dont work does nothing
PHP код:
//-------------------------------------------------ROLE PLAY BY DaYviSoN---------------------------------------------//
#include <a_samp>
#include <dini>
#undef MAX_VEHICLES
#define MAX_VEHICLES 850
#pragma unused strtok
//Tela que aparece no samp-server. (Quando se liga o servidor)
main()
{
print(" ");
print("_______________________________________________________________");
print("Estado do Servidor: ");
print("O Servidor foi ligado com sucesso! Estб Pronto a ser Utilizado.");
print("_______________________________________________________________");
print(" ");
}
//--------------------
public OnGameModeInit()
{
// Modo de Jogo
SetGameModeText("RolePlay v1.0");
//Player
AddPlayerClass(0, -767.3870,1499.8663,24.7051, 269.1425, 0, 0, 0, 0, 0, 0);
// Veiculos
AddStaticVehicle(431,-774.5818,1444.2756,13.8953,77.9480,47,74);
AddStaticVehicle(431,-774.1534,1428.5939,13.8890,102.9080,47,74);
AddStaticVehicle(574,-791.8569,1445.9147,13.5142,78.0698,26,26);
AddStaticVehicle(574,-791.9972,1427.2260,13.5142,104.1815,26,26);
AddStaticVehicle(574,-806.3814,1446.4915,13.5142,76.4160,26,26);
AddStaticVehicle(574,-806.3204,1427.0098,13.5142,103.9668,26,26);
AddStaticVehicle(599,-221.1601,1005.3596,19.8951,180.0661,0,1);
AddStaticVehicle(525,-216.7263,1005.1966,19.6012,182.4167,52,54);
return 1;
}
//--------------------
public OnGameModeExit()
{
return 1;
}
//--------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[128];
if (strcmp(cmdtext, "/comprarcarro", true) == 0)
{
new VehicleID;
VehicleID = GetPlayerVehicleID(playerid);
new pname[MAX_PLAYER_NAME];
new aname[MAX_PLAYER_NAME];
new file[128];
GetPlayerName(playerid, aname, sizeof(aname));
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "Contas/%s.ini", aname);
for (new carro = 0; carro < MAX_VEHICLES; carro++)
{
format(string, sizeof(string), "carro%d.ini", carro);
if (strfind(pname,dini_Get(string,"Dono"),true) == 0)
{
SendClientMessage(playerid, -1, "Vocк jб tem um carro");
return 1;
}
if (IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0 && VehicleID == dini_Int(string, "Id"))
{
if (dini_Int(string, "TDono") == 1) return SendClientMessage(playerid, -1, "Esse Carro jб tem dono!");
if (GetPlayerMoney(playerid) >= dini_Int(string, "Preco"))
{
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
dini_IntSet(string, "TDono", 1);
dini_Set(string, "Dono", aname);
SendClientMessage(playerid, -1, "(INFO) Veiculo comprado com sucesso!");
SendClientMessage(playerid, -1, "(INFO) Para ver os comandos do veiculo, use: /meucarro");
GivePlayerMoney(playerid, -dini_Int(string, "Preco"));
TogglePlayerControllable(playerid, 1);
return 1;
} else {
SendClientMessage(playerid, -1, "(ERRO) Vocк nгo tem dinheiro suficiente!");
return 1;
}
}
}
return 1;
}
return 0;
}
//--------------------Quando o Player Conecta-------------
public OnPlayerConnect(playerid) {
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(string, sizeof string, "%s entrou no servidor!", pName);
SendClientMessageToAll(0xFFFFFFAA, string);
SendClientMessage(playerid,0xFF7F00FF,"A entrar...");
SetPlayerCameraPos(playerid, -204.1585,1106.1953,159.7422);
SetPlayerCameraLookAt(playerid,-204.1585,1106.1953,19.7422);
return 1;
}
//--------------------Quando o Player Disconecta----------
public OnPlayerDisconnect(playerid, reason) {
new
string[64], name[MAX_PLAYER_NAME]
;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
switch (reason) {
case 0:
format(string, sizeof string, "%s saiu do servidor. (Problema de Conexгo)", name);
case 1:
format(string, sizeof string, "%s saiu do servidor. (Saiu)", name);
case 2:
format(string, sizeof string, "%s saiu do servidor. (Kick/Ban)", name);
}
SendClientMessageToAll(0xFFFFFFAA, string);
return 1;
}
//-----------------------
stock strtoks(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
I cant, when i remove iti got 16 errors. :S