CMD:pgoto(playerid,params[]) { if(PlayerInfo[playerid][LoggedIn] == 0) { SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You need to be registered to access this command"); return 1; } new teleid; if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, red, "Usage:/pgoto [playerid]"); if(!IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected"); if(teleid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "This isn't a valid player ID"); if(tele[teleid]==1) return SendClientMessage(playerid, red, "Player has not enabled tele command"); new Float:telex,Float:teley,Float:telez,int; GetPlayerPos(teleid,telex,teley,telez); int = GetPlayerInterior(teleid); if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vid = GetPlayerVehicleID(playerid); SetVehiclePos(vid, telex, teley, telez+1); LinkVehicleToInterior(vid, int); } else { SetPlayerPos(playerid,telex,teley,telez+1); SetPlayerInterior(playerid,int); } return 1; }
new last_pgoto[MAX_PLAYERS];
// inside the command
// under the logged in check
if((gettime() - last_pgoto[playerid]) < 5)
return SendClientMessage(playerid, -1, "wait");
// above return line
last_pgoto[playerid] = gettime();
CMDgoto(playerid,params[]) { if(PlayerInfo[playerid][LoggedIn] == 0) { SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You need to be registered to access this command"); return 1; } new teleid; if(sscanf(params,"u",teleid)) return SendClientMessage(playerid, red, "Usage:/pgoto [playerid]"); if(!IsPlayerConnected(teleid)) return SendClientMessage(playerid, red, "Player is not connected"); if(teleid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "This isn't a valid player ID"); if(tele[teleid]==1) return SendClientMessage(playerid, red, "Player has not enabled tele command"); new Float:telex,Float:teley,Float:telez,int; GetPlayerPos(teleid,telex,teley,telez); int = GetPlayerInterior(teleid); new last_pgoto[MAX_PLAYERS]; if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vid = GetPlayerVehicleID(playerid); SetVehiclePos(vid, telex, teley, telez+1); LinkVehicleToInterior(vid, int); if((gettime() - last_pgoto[playerid]) < 5) return SendClientMessage(playerid, -1, "wait"); } else { SetPlayerPos(playerid,telex,teley,telez+1); SetPlayerInterior(playerid,int); } last_pgoto[playerid] = gettime(); return 1; } |
new last_pgoto[MAX_PLAYERS];
CMD:pgoto(playerid,params[]) {
if(PlayerInfo[playerid][LoggedIn] == 0) {
SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You need to be registered to access this command");
return 1;
}
if((gettime() - last_pgoto[playerid]) < 5) {
SendClientMessage(playerid, COLOR_BRIGHTRED, "Error: You must wait 5 seconds before using this command again.");
return 1;
}
new teleid;
if(sscanf(params,"u",teleid)) {
return SendClientMessage(playerid, red, "Usage:/pgoto [playerid]");
}
if(!IsPlayerConnected(teleid)) {
return SendClientMessage(playerid, red, "Player is not connected");
}
if(teleid == INVALID_PLAYER_ID) {
return SendClientMessage(playerid, red, "This isn't a valid player ID");
}
if(tele[teleid]==1) {
return SendClientMessage(playerid, red, "Player has not enabled tele command");
}
new Float:telex,Float:teley,Float:telez,int;
GetPlayerPos(teleid,telex,teley,telez);
int = GetPlayerInterior(teleid);
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
new vid = GetPlayerVehicleID(playerid);
SetVehiclePos(vid, telex, teley, telez+1);
LinkVehicleToInterior(vid, int);
}
else {
SetPlayerPos(playerid,telex,teley,telez+1);
SetPlayerInterior(playerid,int);
}
last_pgoto[playerid] = gettime();
return 1;
}