16.09.2013, 08:29
Hello,
I'm currently working on a /drag command for LEO factions for my RP server, and I've attempted to create a /drag command earlier but failed. Now I wanted to see if I notice the problem, but I failed again and I'm hopeless. I can't find the problem at all. Can anyone take a look at my code and tell me what I've done wrong etc? I don't need a fixed code. I want to learn it myself. It crashes my pawn compiler too though, I think I've missed a closing or opening bracket but I can't find where. Thanks in advance.
Command
Public + forward
Regards, Sidney.
I'm currently working on a /drag command for LEO factions for my RP server, and I've attempted to create a /drag command earlier but failed. Now I wanted to see if I notice the problem, but I failed again and I'm hopeless. I can't find the problem at all. Can anyone take a look at my code and tell me what I've done wrong etc? I don't need a fixed code. I want to learn it myself. It crashes my pawn compiler too though, I think I've missed a closing or opening bracket but I can't find where. Thanks in advance.
Command
pawn Код:
YCMD:drag(playerid, params[], help) {
if(help) {
SendClientMessage(playerid, X11_WHITE, "Drags a player");
return 1;
}
if(!IsAnLEO(playerid)) {
SendClientMessage(playerid, X11_TOMATO_2, "You are not a cop!");
return 1;
}
if(!IsOnDuty(playerid)) {
SendClientMessage(playerid, X11_TOMATO_2, "You are not on duty!");
return 1;
}
new player;
//new user;
if(!sscanf(params,"k<playerLookup>", player)) {
if(!IsPlayerConnectEx(player)) {
SendClientMessage(playerid, X11_TOMATO_2, "User not found");
return 1;
}
new Float:X, Float:Y, Float:Z;
GetPlayerPos(player, X, Y, Z);
if(!IsPlayerInRangeOfPoint(playerid, 2.5, X, Y, Z)) {
SendClientMessage(playerid, X11_TOMATO_2, "You are too far away");
return 1;
}
if(!IsPlayerConnectEx(player)) {
SendClientMessage(playerid, X11_TOMATO_2, "User not found");
return 1;
}
if(GetPVarType(player, "CuffTime") == PLAYER_VARTYPE_NONE) {
SendClientMessage(playerid, X11_TOMATO_2, "This person isn't cuffed!");
return 1;
}
new string[128];
if(GetPVarInt(user, "Dragged") == 0) {
if(GetDistanceBetweenPlayers(playerid, player) < 7) {
//new rank = GetPVarInt(playerid, "Rank");
format(string, sizeof(string), "* %s %s has started dragging %s.", GetPVarInt(playerid, "Rank"), GetPlayerNameEx(playerid, ENameType_RPName), GetPlayerNameEx(player, ENameType_RPName));
ProxMessage(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(player, "Dragged", 1);
draggingtimer[player] = SetTimerEx("draggingtimer", 1000, true, "ii", playerid, player); // Updates position every second
TogglePlayerControllable(player, 0);
return 1;
}
}
if(GetPVarInt(user, "Dragged") == 1) {
format(string, sizeof(string), "* Officer %s has stopped dragging %s.", GetPlayerNameEx(playerid, ENameType_RPName), GetPlayerNameEx(player, ENameType_RPName));
ProxMessage(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetPVarInt(player, "Dragged", 0);
KillTimer(draggingtimer[player]);
TogglePlayerControllable(player, 1);
return 1;
}
} else {
SendClientMessage(playerid, X11_WHITE, "USAGE: /drag [playerid/name]");
}
return 1;
}
pawn Код:
forward draggingtimer(playerid);
public draggingtimer(playerid)
{
new playa;
new Float:X, Float:Y, Float:Z;
new interior = GetPlayerInterior(playerid);
new vw = GetPlayerVirtualWorld(playerid);
SetPlayerVirtualWorld(playa, vw);
SetPlayerInterior(playa, interior);
GetPlayerPos(playerid, X, Y, Z);
SetPlayerPos(playa, X, Y, Z);
return 1;
}