?CMD:gift(playerid, params[])
{
new option[32], type[32], string[100];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] <5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on Admin Duty.");
if(sscanf(params, "s[32]", option))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /gift [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: Create, Remove");
return 1;
}
if(!strcmp(option, "create", true))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new File:presents=fopen("presents.cfg", io_append);
format(string, sizeof(string), "%d, %d, %d\r\n", x, y, z);
fwrite(presents, string);
fclose(presents);
if(sscanf(params, "s[32]s[32]", option, type))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /gift option [type]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: Gift1, Gift2, Gift3, Gift4, Gift5");
return 1;
}
if(!strcmp(type, "gift1", true))
{
Gift1 =1;
new GiftBox1 = CreateDynamicObject(19054, x, y, z, 0.00000, 0.00000, 0.00000, 0, 0, -1, 200.0);
IsValidDynamicObject(GiftBox1);
return 1;
}
if(!strcmp(type, "gift2", true))
{
Gift2 =1;
new GiftBox2 = CreateDynamicObject(19055, x, y, z, 0.00000, 0.00000, 0.00000, 0, 0, -1, 200.0);
IsValidDynamicObject(GiftBox2);
return 1;
}
if(!strcmp(type, "gift3", true))
{
Gift3 =1;
new GiftBox3 = CreateDynamicObject(19056, x, y, z, 0.00000, 0.00000, 0.00000, 0, 0, -1, 200.0);
IsValidDynamicObject(GiftBox3);
return 1;
}
if(!strcmp(type, "gift4", true))
{
Gift4 =1;
new GiftBox4 = CreateDynamicObject(19057, x, y, z, 0.00000, 0.00000, 0.00000, 0, 0, -1, 200.0);
IsValidDynamicObject(GiftBox4);
return 1;
}
if(!strcmp(type, "gift5", true))
{
Gift5 =1;
new GiftBox5 = CreateDynamicObject(19058, x, y, z, 0.00000, 0.00000, 0.00000, 0, 0, -1, 200.0);
IsValidDynamicObject(GiftBox5);
return 1;
}
return 1;
}
else if(!strcmp(option, "remove", true))
{
// Code...
return 1;
}
return 1;
}
if(!strcmp(option, "create", true))
|
length (optional) When this length is set, the first x chars will be compared - doing "Hello" and "Hell No" with a length of 4 will say it's the same string. |
if(sscanf(params, "s[32]S(0)[32]",option, type))
{
SendClientMessage(playerid, COLOR_WHITE, "** [Usage]: /gift [option]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: Create, Remove");
return 1;
}
|
SSCANF is the issue here, also.
You would have to use an optional parameter, this will work better. Like this: pawn Код:
ALSO: This tutorial cleared this up a hell of a lot for me. https://sampforum.blast.hk/showthread.php?tid=250454 |
CMD:open(playerid, params[])
{
new string[100], GiftBox1, GiftBox2, GiftBox3, GiftBox4, GiftBox5;
/*new File:presents=fopen("presents.cfg", io_read);
fclose(presents);
if(IsPlayerInRangeOfPoint(playerid, 10.0, 23.213,2442.2424,242.214))
{
SendClientMessage(playerid, COLOR_GREY, "You're not in range of any Presents at the moment.");
return 1;
}*/
if(Gift1 == 1)
{
format(string, sizeof(string), "Congrats you were givin $10,000 from this package.");
SendClientMessage(playerid, COLOR_WHITE, string);
GiveDodMoney(playerid, 10000); // This is just a test, you can change it later.
DestroyDynamicObject(GiftBox1);
Gift1 =0;
return 1;
}
if(Gift2 == 1)
{
format(string, sizeof(string), "Congrats you were givin $5,000 from this package.");
SendClientMessage(playerid, COLOR_WHITE, string);
GiveDodMoney(playerid, 5000); // This is just a test, you can change it later.
DestroyDynamicObject(GiftBox2);
Gift2 =0;
return 1;
}
if(Gift3 == 1)
{
format(string, sizeof(string), "Congrats you were givin $11,000 from this package.");
SendClientMessage(playerid, COLOR_WHITE, string);
GiveDodMoney(playerid, 11000); // This is just a test, you can change it later.
DestroyDynamicObject(GiftBox3);
Gift3 =0;
return 1;
}
if(Gift4 == 1)
{
format(string, sizeof(string), "Congrats you were givin $12,000 from this package.");
SendClientMessage(playerid, COLOR_WHITE, string);
GiveDodMoney(playerid, 12000); // This is just a test, you can change it later.
DestroyDynamicObject(GiftBox4);
Gift4 =0;
return 1;
}
if(Gift5 == 1)
{
format(string, sizeof(string), "Congrats you were givin $19,000 from this package.");
SendClientMessage(playerid, COLOR_WHITE, string);
GiveDodMoney(playerid, 19000); // This is just a test, you can change it later.
DestroyDynamicObject(GiftBox5);
Gift5 =0;
return 1;
}
return 1;
}
#define MAX_GIFTS 100 //Or whatever amount you want to be maximum..
new Float: GiftX[MAX_GIFTS];
new Float: GiftY[MAX_GIFTS];
new Float: GiftZ[MAX_GIFTS];
//Under the command /gift create
new Float: x, y, z;
GetPlayerPos(playerid, x, y, z);
//loop through all gifts to get the ID
new giftid = i;
GiftX[giftid] = x;
GiftY[giftid] = y;
GiftZ[giftid]= z;
// on /open do this....
for(new giftid = 1; giftid < MAX_GIFTS; giftid ++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, GiftX[giftid], GiftY[giftid], GiftZ[giftid]);
//Give them a gift etc.
}