PDA

View Full Version : sscanf ID 0 bug


Lidor124
19/03/2014, 06:34 PM
Hi all
I have problem with sscanf, i have the latest sscanf version 2.8.1 + plugin + include <sscanf2>
There what happend:
i was playerid 0 and my friend did /drag command on playerid 5, then playerid 5 was dragged by me like teleport.

Please help

/drag command

CMD:drag(playerid, params[])
{
new string[128], giveplayerid;
if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, " You are not a LEO ! ");
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");
{
if(Dragging[playerid] == 0)
{
new Float:dX, Float:dY, Float:dZ;
GetPlayerPos(giveplayerid, dX, dY, dZ);
if(!IsPlayerInRangeOfPoint(playerid, 5.0, dX, dY, dZ)) return SendClientMessageEx(playerid, COLOR_GRAD2, " That suspect is not near you.");

if(playerid == giveplayerid) return SendClientMessage(playerid, COLOR_GRAD2, "You can't drag yourself.");

if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GRAD2, "This player is not online.");

if(IsPlayerInAnyVehicle(playerid) || IsPlayerInAnyVehicle(giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, " You must be out of the vehicle to use this command.");

// if(PlayerTied[giveplayerid] != 1 || PlayerCuffed[giveplayerid] != 2) return SendClientMessageEx(playerid, COLOR_WHITE, "The player is not cuffed nor tied.");

if(!GetPVarInt(giveplayerid, "IsFrozen")) return SendClientMessageEx(playerid, COLOR_WHITE, "The player is not cuffed nor tied.");

Dragged[giveplayerid] = 1;
Dragging[playerid] = 1;
format(string, sizeof(string), "You are being dragged by %s.", GetPlayerNameEx(playerid));
SendClientMessageEx(giveplayerid, COLOR_PURPLE, string);
format(string, sizeof(string), " You are dragging %s.", GetPlayerNameEx(giveplayerid));
SendClientMessageEx(playerid, COLOR_PURPLE, string);
format(string, sizeof(string), "* %s pulls %s and starts dragging him.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
ClearAnimations(playerid);
// draggedtimer[giveplayerid] = SetTimerEx("Draggingt", 500, 1, "dd", playerid, giveplayerid);
}
else
{
if(Dragging[playerid] == 1)
{
Dragged[giveplayerid] = 0;
Dragging[playerid] = 0;
format(string, sizeof(string), "You have stopped dragging %s.", GetPlayerNameEx(giveplayerid));
SendClientMessageEx(playerid, COLOR_PURPLE, string);
SendClientMessageEx(giveplayerid, COLOR_PURPLE, "You aren't being dragged anymore.");
format(string, sizeof(string), "* %s has stopped dragging %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
// KillTimer(draggedtimer[playerid]);
// KillTimer(draggedtimer[giveplayerid]);
}
}
}
return 1;
}

Sascha
19/03/2014, 06:46 PM
first try to add an "else" infront of your "{" after the sscanf part check

if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /drag [playerid]");
else
{