Command no work
#1

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(playeridcmdtext[])
{
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(playeridanamesizeof(aname));
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(filesizeof(file), "Contas/%s.ini"aname);
    for (new 
carro 0carro MAX_VEHICLEScarro++)
    {
    
format(stringsizeof(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) == && 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(playeridanameMAX_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(playerid3);
                return 
1;
            } else {
                
SendClientMessage(playerid, -1"(ERRO) Vocк nгo tem dinheiro suficiente!");
                return 
1;
            }
        }
    }
    return 
1;
}
return 
0;

Reply
#2

Well for one, TogglePlayerControllable(playerid, 3); 3 is not an option, it's either 0 or 1.
Reply
#3

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?
Reply
#4

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.
Reply
#5

So i put TogglePlayerControllable 1 rigth?

Sorry my bad english
Reply
#6

Yes, but you've got to be inside the vehicle too. Are you sure you're inside an vehicle & you're it's driver?
Reply
#7

i puted TogglePlayerControllable 1 and i was in vehicle and im the driver and dont work does nothing


There is my gamemode he have just 138 Lines

















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.7051269.1425000000);
    
// 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(playeridcmdtext[])
{
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(playeridanamesizeof(aname));
    
GetPlayerName(playeridpnamesizeof(pname));
    
format(filesizeof(file), "Contas/%s.ini"aname);
    for (new 
carro 0carro MAX_VEHICLEScarro++)
    {
    
format(stringsizeof(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) == && 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(playeridanameMAX_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(playerid1);
                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(playeridpNameMAX_PLAYER_NAME);
    
format(stringsizeof string"%s entrou no servidor!"pName);
    
SendClientMessageToAll(0xFFFFFFAAstring);
    
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(playeridreason) {
    new
        
string[64], name[MAX_PLAYER_NAME]
    ;
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    switch (
reason) {
    case 
0:
        
format(stringsizeof string"%s saiu do servidor. (Problema de Conexгo)"name);
    case 
1:
        
format(stringsizeof string"%s saiu do servidor. (Saiu)"name);
    case 
2:
        
format(stringsizeof string"%s saiu do servidor. (Kick/Ban)"name);
    }
    
SendClientMessageToAll(0xFFFFFFAAstring);
    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;

Reply
#8

remove the return 0;
Reply
#9

I cant, when i remove iti got 16 errors. :S
Reply
#10

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
remove the return 0;
When i remove it i got 16 errors xD
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)