CMD:usedrug(playerid, params[])
{
if(LoggedIn[playerid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(Cocaine[playerid] && Weed[playerid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not have any drugs to use.");
new usage[24], string[128];
if(sscanf(params, "s[24]", usage)) return SendClientMessage(playerid, COLOUR_GREY, "USAGE: /usedrug [drug] - Drug types: weed, coke.");
if(strcmp(usage, "coke", true))
{
if(IsDrugged[playerid] == 1) return SendClientMessage(playerid, COLOUR_GREY, "You are already using drugs.");
SetPlayerWeather(playerid, 39);
SetPlayerDrunkLevel(playerid, 3000);
Cocaine[playerid] = Cocaine[playerid] - 1;
DrugUsed[playerid] = 1;
IsDrugged[playerid] = 1;
DruggedTime[playerid] = 45;
PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
MySQL_SetInteger(PlayerSQLID[playerid], "Cocaine", Cocaine[playerid], "accounts");
SetTimer("DruggedTimer", 1000, 1);
format(string, sizeof(string), "You have taken 1 gram of cocaine, you will recieve an armour boost after the effects wear off.");
SendClientMessage(playerid, COLOUR_WHITE, string);
}
if(strcmp(usage, "weed", true))
{
if(IsDrugged[playerid] == 1) return SendClientMessage(playerid, COLOUR_GREY, "You are already using drugs.");
SetPlayerWeather(playerid, 20);
SetPlayerDrunkLevel(playerid, 3000);
Weed[playerid] = Weed[playerid] - 1;
DrugUsed[playerid] = 2;
DruggedTime[playerid] = 45;
PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
MySQL_SetInteger(PlayerSQLID[playerid], "Weed", Weed[playerid], "accounts");
SetTimer("DruggedTimer", 1000, 1);
format(string, sizeof(string), "You have taken 1 gram of weed, you will recieve a health boost after the effects wear off.");
SendClientMessage(playerid, COLOUR_WHITE, string);
}
return 1;
}
CMD:usedrug(playerid, params[])
{
if(LoggedIn[playerid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(Cocaine[playerid] && Weed[playerid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "You do not have any drugs to use.");
new usage[24], string[128];
if(sscanf(params, "s[24]", usage)) return SendClientMessage(playerid, COLOUR_GREY, "USAGE: /usedrug [drug] - Drug types: weed, coke.");
if(!strcmp(usage, "coke", true))
{
if(IsDrugged[playerid] == 1) return SendClientMessage(playerid, COLOUR_GREY, "You are already using drugs.");
SetPlayerWeather(playerid, 39);
SetPlayerDrunkLevel(playerid, 3000);
Cocaine[playerid] = Cocaine[playerid] - 1;
DrugUsed[playerid] = 1;
IsDrugged[playerid] = 1;
DruggedTime[playerid] = 45;
PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
MySQL_SetInteger(PlayerSQLID[playerid], "Cocaine", Cocaine[playerid], "accounts");
SetTimer("DruggedTimer", 1000, 1);
format(string, sizeof(string), "You have taken 1 gram of cocaine, you will recieve an armour boost after the effects wear off.");
SendClientMessage(playerid, COLOUR_WHITE, string);
}
if(!strcmp(usage, "weed", true))
{
if(IsDrugged[playerid] == 1) return SendClientMessage(playerid, COLOUR_GREY, "You are already using drugs.");
SetPlayerWeather(playerid, 20);
SetPlayerDrunkLevel(playerid, 3000);
Weed[playerid] = Weed[playerid] - 1;
DrugUsed[playerid] = 2;
DruggedTime[playerid] = 45;
PlayerSQLID[playerid] = MySQL_GetValue(PlayerSQLID[playerid], "id", "accounts");
MySQL_SetInteger(PlayerSQLID[playerid], "Weed", Weed[playerid], "accounts");
SetTimer("DruggedTimer", 1000, 1);
format(string, sizeof(string), "You have taken 1 gram of weed, you will recieve a health boost after the effects wear off.");
SendClientMessage(playerid, COLOUR_WHITE, string);
}
return 1;
}
pawn Код:
|
if(str,"Coke")
{
//code
It's not stupid because it's not "strsame", it's "strcmp" - COMPARE the strings and return the DIFFERENCE. If they're the same there's no difference, i.e. 0. People get confused because they assume they know what functions do based on a cursory reading of what they're commonly used for and what they think they know about other languages which I keep trying to tell them aren't PAWN.
|
But why does it has to be if(strcmp / if(!strcmp).
Can't it be something like pawn Код:
|
#define IsSame(%0,%1) !strcmp(%0,%1,true,strlen(%1)) //Newbie def. ;)
//Example:
if(IsSame("SOMEBULLSHITINEVEREXPECTED","SOMEBULLSHITINEVEREXPECTED"))
{
print("ok!");
}
//will print: ok!
OR:
#define strsame !strcmp
if(strsame("ABC123", "ABC123", true, 6))
{
print("fdok!");
}