Help in CMD's
#1

Look at those :

Quote:

}
if (strcmp("/Buyhealth", cmdtext, true, 5) == 0)
{
SetPlayerHealth(playerid, 100.0);
GivePlayerMoney(playerid, -10000);
return 1;
}
if (strcmp("/BuyArmor", cmdtext, true, 5) == 0)
{
SetPlayerArmour(playerid, 100.0);
GivePlayerMoney(playerid, -10000);
return 1;
}

Those 2 CMD's are working fine , but the problem that if you have 0 and you do /buyarmor - /buyhealth , you get -10000 , i want that if you have less than 10k it say : Error : You Don't have Enough Cash



And also if a player do /buyarm - /buyarmoooooooor or something like this it also give him armor for 10k , but i want that ONLY /buyarmor works , any help ?
Reply
#2

pawn Код:
if (strcmp("/Buyhealth", cmdtext, true, 10) == 0) //The 10 here is the length of the command, not 100% sure if you need to include the /, so if 10 doesnt work make it 9, same for the armor cmd. (9 > 8)
{
    new money;
    GetPlayerMoney(playerid, money);
    if(money < 10000) return SendClientMessage(playerid, -1, "You can't afford this!");
    SetPlayerHealth(playerid, 100.0);
    GivePlayerMoney(playerid, -10000);
    return 1;
}
if (strcmp("/BuyArmor", cmdtext, true, 9) == 0)
{
    new money;
    GetPlayerMoney(playerid, money);
    if(money < 10000) return SendClientMessage(playerid, -1, "You can't afford this!");
    GetPlayerArmour(playerid, armor);
    SetPlayerArmour(playerid, 100.0);
    GivePlayerMoney(playerid, -10000);
    return 1;
}
Reply
#3

Did that :

Quote:

if (strcmp("/Buyhealth", cmdtext, true, 10) == 0)
{
new money;
GetPlayerMoney(playerid, money);
if(money < 10000) return SendClientMessage(playerid, -1, "You can't afford this!");
SetPlayerHealth(playerid, 100.0);
GivePlayerMoney(playerid, -10000);
return 1;
}
if (strcmp("/BuyArmor", cmdtext, true, 9) == 0)
{
new money;
GetPlayerMoney(playerid, money);
if(money < 10000) return SendClientMessage(playerid, -1, "You can't afford this!");
GetPlayerArmour(playerid, armor);
SetPlayerArmour(playerid, 100.0);
GivePlayerMoney(playerid, -10000);
return 1;
}
return 0;
}

And that happened :

Quote:

E:\LOSSAN~1\GAMEMO~1\LSGW2.pwn(102) : warning 217: loose indentation
E:\LOSSAN~1\GAMEMO~1\LSGW2.pwn(105) : warning 202: number of arguments does not match definition
E:\LOSSAN~1\GAMEMO~1\LSGW2.pwn(111) : warning 217: loose indentation
E:\LOSSAN~1\GAMEMO~1\LSGW2.pwn(114) : warning 202: number of arguments does not match definition
E:\LOSSAN~1\GAMEMO~1\LSGW2.pwn(116) : error 017: undefined symbol "armor"
E:\LOSSAN~1\GAMEMO~1\LSGW2.pwn(121) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#4

pawn Код:
if (strcmp("/Buyhealth", cmdtext, true, 10) == 0)
{
    if(GetPlayerMoney(playerid) < 10000)
    {
        SendClientMessage(playerid, -1, "You can't afford this!");
        return 1;
    }
    SetPlayerHealth(playerid, 100.0);
    GivePlayerMoney(playerid, -10000);
    return 1;
}
if (strcmp("/BuyArmor", cmdtext, true, 10) == 0)
{
    if(GetPlayerMoney(playerid) < 10000)
    {
        SendClientMessage(playerid, -1, "You can't afford this!");
        return 1;
    }
    SetPlayerArmour(playerid, 100.0);
    GivePlayerMoney(playerid, -10000);
    return 1;
}
Reply
#5

Sorry for Double post but look : , When i tried to make it like first this happened :


Quote:

#include <a_samp>

#define TEAM_GROVE 1
#define TEAM_BALLA 2
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

new gTeam[MAX_PLAYERS];

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

public OnGameModeInit()
{
SetGameModeText("L.S.G.W");
AddPlayerClass(102,2001.1736,-1122.1942,26.6893,179.8825, 24, 500, 27, 500, 31, 500);
AddPlayerClass(107,2521.5156,-1678.9836,15.4372,92.7751, 24, 500, 27, 500, 31, 500);

//--------------------------------------------------------------Cars-----------------------------
AddStaticVehicle(567,2469.7935,-1653.6843,13.2708,90.5193,16,16); // Grove Car ne
AddStaticVehicle(550,2499.4294,-1654.7576,13.2485,254.4190,16,16); // Grove Car two
AddStaticVehicle(445,2506.7881,-1678.3098,13.3342,325.9603,16,16); // Grove Car Three
AddStaticVehicle(580,2474.8115,-1680.0529,13.1468,53.0098,16,16); // Grove Car Four
AddStaticVehicle(554,2473.1538,-1692.3916,13.6217,358.9131,16,16); // Grove car Six
AddStaticVehicle(575,2027.4512,-1141.2002,24.2388,268.0392,174,174); // Ballaz car one
AddStaticVehicle(566,1996.3920,-1130.7765,25.2881,268.9091,174,174); // Ballaz car two
AddStaticVehicle(566,2009.3124,-1131.0549,24.9350,270.7833,174,174); // Ballaz car three
AddStaticVehicle(517,2037.6184,-1131.2960,24.1986,268.1283,174,174); // Ballaz car four
AddStaticVehicle(517,1983.9332,-1140.4438,25.6544,270.9725,174,174); // Ballaz car five
AddStaticVehicle(445,2004.6111,-1141.2178,25.1558,269.5776,174,174); // Ballaz car six
AddStaticVehicle(576,2018.9581,-1140.7462,24.4843,267.8231,174,174); // Ballaz car seven
AddStaticVehicle(576,2051.8625,-1120.1655,24.3129,180.2631,174,174); // Ballaz car Eight
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
if(classid == 1)
{
gTeam[playerid] = TEAM_GROVE;
SetPlayerColor(playerid, TEAM_GROVE_COLOR);
}
else
{
gTeam[playerid] = TEAM_BALLA;
SetPlayerColor(playerid, TEAM_BALLA_COLOR);
}
return 1;
}


public OnPlayerConnect(playerid)
{
GameTextForPlayer(playerid,"~b~Welcome to Los Santos Gangs War",3000,6);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
GameTextForPlayer(playerid,"~r~Wasted",3000,2);
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kill", cmdtext, true, 5) == 0)
{
SetPlayerHealth(playerid, 0.0);
return 1;
}
return 0;
}
if (strcmp("/Buyhealth", cmdtext, true, 5) == 0)
{
SetPlayerHealth(playerid, 100.0);
GivePlayerMoney(playerid, -10000);
return 1;
}
if (strcmp("/BuyArmor", cmdtext, true, 5) == 0)
{
SetPlayerArmour(playerid, 100.0);
GivePlayerMoney(playerid, -10000);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}


This happened :


Quote:

E:\Los Santos Gangs Wars\gamemodes\LSGW.pwn(104) : error 010: invalid function or declaration
E:\Los Santos Gangs Wars\gamemodes\LSGW.pwn(10 : error 010: invalid function or declaration
E:\Los Santos Gangs Wars\gamemodes\LSGW.pwn(110) : error 010: invalid function or declaration
E:\Los Santos Gangs Wars\gamemodes\LSGW.pwn(114) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#6

Use this:
pawn Код:
#include <a_samp>

#define TEAM_GROVE 1
#define TEAM_BALLA 2
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

new gTeam[MAX_PLAYERS];

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    SetGameModeText("L.S.G.W");
    AddPlayerClass(102,2001.1736,-1122.1942,26.6893,179.8825, 24, 500, 27, 500, 31, 500);
    AddPlayerClass(107,2521.5156,-1678.9836,15.4372,92.7751, 24, 500, 27, 500, 31, 500);

    //--------------------------------------------------------------Cars-----------------------------
    AddStaticVehicle(567,2469.7935,-1653.6843,13.2708,90.5193,16,16); // Grove Car ne
    AddStaticVehicle(550,2499.4294,-1654.7576,13.2485,254.4190,16,16); // Grove Car two
    AddStaticVehicle(445,2506.7881,-1678.3098,13.3342,325.9603,16,16); // Grove Car Three
    AddStaticVehicle(580,2474.8115,-1680.0529,13.1468,53.0098,16,16); // Grove Car Four
    AddStaticVehicle(554,2473.1538,-1692.3916,13.6217,358.9131,16,16); // Grove car Six
    AddStaticVehicle(575,2027.4512,-1141.2002,24.2388,268.0392,174,174); // Ballaz car one
    AddStaticVehicle(566,1996.3920,-1130.7765,25.2881,268.9091,174,174); // Ballaz car two
    AddStaticVehicle(566,2009.3124,-1131.0549,24.9350,270.7833,174,174); // Ballaz car three
    AddStaticVehicle(517,2037.6184,-1131.2960,24.1986,268.1283,174,174); // Ballaz car four
    AddStaticVehicle(517,1983.9332,-1140.4438,25.6544,270.9725,174,174); // Ballaz car five
    AddStaticVehicle(445,2004.6111,-1141.2178,25.1558,269.5776,174,174); // Ballaz car six
    AddStaticVehicle(576,2018.9581,-1140.7462,24.4843,267.8231,174,174); // Ballaz car seven
    AddStaticVehicle(576,2051.8625,-1120.1655,24.3129,180.2631,174,174); // Ballaz car Eight
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    if(classid == 1)
    {
        gTeam[playerid] = TEAM_GROVE;
        SetPlayerColor(playerid, TEAM_GROVE_COLOR);
    }
    else
    {
        gTeam[playerid] = TEAM_BALLA;
        SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
    return 1;
}


public OnPlayerConnect(playerid)
{
    GameTextForPlayer(playerid,"~b~Welcome to Los Santos Gangs War",3000,6);
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    GameTextForPlayer(playerid,"~r~Wasted",3000,2);
    return 1;
}

public OnVehicleSpawn(vehicleid)
    {
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/kill", cmdtext, true, 5) == 0)
    {
        SetPlayerHealth(playerid, 0.0);
        return 1;
    }
    if (strcmp("/Buyhealth", cmdtext, true, 10) == 0)
    {
        if(GetPlayerMoney(playerid) < 10000)
        {
            SendClientMessage(playerid, -1, "You can't afford this!");
            return 1;
        }
        SetPlayerHealth(playerid, 100.0);
        GivePlayerMoney(playerid, -10000);
        return 1;
    }
    if (strcmp("/BuyArmor", cmdtext, true, 10) == 0)
    {
        if(GetPlayerMoney(playerid) < 10000)
        {
            SendClientMessage(playerid, -1, "You can't afford this!");
            return 1;
        }
        SetPlayerArmour(playerid, 100.0);
        GivePlayerMoney(playerid, -10000);
        return 1;
    }
    return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)