02.12.2014, 22:17
How to go to drive on water?
native TogglePlayerDriveOnWater(playerid, bool:toggle);
public OnPlayerText(playerid,text[])
{
if(strcmp(text, "waterfun", true) == 0)
{
if(!IsPlayerSAMPP(playerid)) return SendClientMessage(playerid, -1, "You do not have the SA:MP plugin.");
if(WaterFun[playerid] == true)
{
TogglePlayerDriveOnWater(playerid, false);
WaterFun[playerid] = false;
GameTextForPlayer(playerid, "Cheat De-Activated", 2, 10000);
return 1;
}
else
{
TogglePlayerDriveOnWater(playerid, true);
WaterFun[playerid] = true;
GameTextForPlayer(playerid, "Cheat Activated", 2, 10000);
return 1;
}
}
return 1;
}
Yeah I forgot about that. I have added IsUsingSAMPP to my example.
|
Here's the wiki link for more information: https://github.com/KingHual/SA-MP-Pl...erDriveOnWater
It would be better to use IsUsingSAMPP to check if the player has the plugin installed. And if he doesn't, you can send a message saying that he needs the plugin. Although it doesn't really matter(the game won't crash), I think it's a nice touch to the command so the player can actually know whether something has taken place or not. And thanks to the guys above for suggesting the plugin, it helps out the project a lot. |
#include <a_samp>
new WalkWaterObject[MAX_PLAYERS];
new bool:WalkingOnWater[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/walkwater", true))
{
if(WalkingOnWater[playerid] == false)
{
WalkWaterObject[playerid] = CreatePlayerObject(playerid, 8661, 0.000000, 0.000000, 0.000000, 178.400314,0.000000,0.000000);
WalkingOnWater[playerid] = true;
SendClientMessage(playerid, 0x00FF00AA, "Walking on water enabled");
return 1;
}
else
{
DestroyPlayerObject(playerid, WalkWaterObject[playerid]);
WalkingOnWater[playerid] = false;
SendClientMessage(playerid, 0xFF0000AA, "Walking on water disabled");
}
return 1;
}
return 0;
}
public OnPlayerDisconnect(playerid, reason)
{
if(WalkingOnWater[playerid] == true)
{
DestroyPlayerObject(playerid, WalkWaterObject[playerid]);
WalkingOnWater[playerid] = false;
}
return 1;
}
public OnPlayerUpdate(playerid)
{
if(WalkingOnWater[playerid] == true)
{
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
if(pos[2] < 2)
{
SetPlayerObjectPos(playerid, WalkWaterObject[playerid], pos[0], pos[1], 0.2);
}
}
return 1;
}