CMD:givemoney(playerid, params[])
{
new playa, money;
if(!IsPlayerAdmin(playerid)) return 1;
if(sscanf(params, "ui", playa, money))
return SendCientMessage(playerid, -1, "USE: /givemoney [playerid] [amount]");
GivePlayerMoney(playerid, -money);
GivePlayerMoney(playa, money);
return 1;
}
CMD:givemoney(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 1;
if(sscanf(params, "ui", params[0], params[1]))
return SendCientMessage(playerid, -1, "USE: /givemoney [playerid] [amount]");
GivePlayerMoney(playerid, -params[1]);
GivePlayerMoney(params[0], params[1]);
return 1;
}
Simple but clear tutorial. By the way, why just admins can givemoney?
![]() |
PHP код:
|
SendClientMessage(playerid,-1, "USE: /givemoney [playerid] [amount]");
GivePlayerMoney(playerid, -params[1]);
A mistake here:
It's PHP код:
PHP код:
|
No, the first version is correct, I don't think you understand how a stack works. Two commands will never be called at the same time, so there will never be 100 variables active at once.
In fact, your method has serious security problems when using optional specifiers and an empty "params". Edit: Also, nothing like this is ever mentioned in the sscanf topic, so I'm not sure why you thought this was the correct way to do it. |
CMD:veh(playerid, params[])
{
new heap = heapspace();
if(GetPVarInt(playerid, "Admin") < 3) return SendClientMessage(playerid, white, "["#Red"»"#White"] Вы не администратор 3 LVL");
new Float:Pos[3];
if(sscanf(params,"i", params[0])) return SendClientMessage(playerid, white, "Использовать: /veh [id автомобиля]");
if(GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]))
{
CreateVehicle(params[0], Pos[0], Pos[1], Pos[2], 90.0, random(128), random(128), 30000);
}
printf("VEH PARAMS STK %d (%d LOSS)", heapspace(), (heap - heapspace()));
return 1;
}
CMD:car(playerid, params[])
{
new heap = heapspace();
new vehicleid;
if(GetPVarInt(playerid, "Admin") < 3) return SendClientMessage(playerid, white, "["#Red"»"#White"] Вы не администратор 3 LVL");
new Float:Pos[3];
if(sscanf(params,"i", vehicleid)) return SendClientMessage(playerid, white, "Использовать: /veh [id автомобиля]");
if(GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]))
{
CreateVehicle(vehicleid, Pos[0], Pos[1], Pos[2], 90.0, random(128), random(128), 30000);
}
printf("CAR VERIABLE STK %d (%d LOSS)", heapspace(), (heap - heapspace()));
return 1;
}
[09/01/13 - 17:23:35] VEH PARAMS STK 16076 (16 LOSS) [09/01/13 - 17:23:42] CAR VERIABLE STK 16104 (20 LOSS)