What's wrong with this code - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What's wrong with this code (
/showthread.php?tid=386167)
What's wrong with this code -
Eminem 2ka9 - 19.10.2012
I simply want this code to spawn me to a location, and give me weapons! Simple...
pawn Код:
//DM By Awankz
//Please Dont Remove Credits
#include <a_samp>
#include <streamer>
#include <core>
#include <float>
#define COLOR_RED 0xAA3333AA
#define COLOR_BLUE 0x33CCFFAA
#define COLOR_ERROR 0xFF6A6AFF
#define COLOR_BOMB 0x96BD6AFF
#define COLOR_ORANGE 0xFF6600
public OnPlayerSpawn(playerid)
{
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/sawndm", true) == 0)
{
SetPlayerPos(playerid, -1314.0879,2541.4563,87.7422);
SendClientMessageToAll(0xFF6600,".: %s has Joined Sawn off Minigame (Sawndm) :.");
PlayerPlaySound(playerid ,3200,0,0,0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
GivePlayerWeapon(playerid, 26, 50000);
GivePlayerWeapon(playerid, 28, 50000);
return 1;
}
return 0;
}
pawn Код:
C:\Users\Administration\Desktop\DM.pwn(37) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Warning.
BUT, I get 1 warning, I skipped the warning but as I went In-game and typed /sawndm, the server didn't recognize this command. "Server: Unknown Command". It says that the warning happend at line 217, but there is no line 217... this is all the code
Re: What's wrong with this code -
gtakillerIV - 19.10.2012
Mate 217 means the warning code not the line, 37 is the line
This should do it:
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/sawndm", true) == 0)
{
SetPlayerPos(playerid, -1314.0879,2541.4563,87.7422);
SendClientMessageToAll(0xFF6600,".: %s has Joined Sawn off Minigame (Sawndm) :.");
PlayerPlaySound(playerid ,3200,0,0,0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
GivePlayerWeapon(playerid, 26, 50000);
GivePlayerWeapon(playerid, 28, 50000);
return 1;
}
return 0;
}
You should go on SA-MP Wiki and learn from there.
Here for example:
https://sampwiki.blast.hk/wiki/Scripting_Basics
And try out ZCMD it's better and faster, if you wanna make errors like "Wrong parameters. Correct Ones: /givecash [PlayerID]" and even more!
Here is more help:
https://sampwiki.blast.hk/wiki/Category:Tutorials
https://sampwiki.blast.hk/wiki/Category:Scripting_Functions
https://sampwiki.blast.hk/wiki/Script_Examples
https://sampwiki.blast.hk/wiki/Category:Scripting_Callbacks
Re : What's wrong with this code -
DaRk_RaiN - 19.10.2012
Here you go tested.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/sawndm", true) == 0)
{
new text[128];
SetPlayerPos(playerid, -1314.0879,2541.4563,87.7422);
format(text, sizeof(text), ": %s has Joined Sawn off Minigame (Sawndm) :.", Name(playerid));
SendClientMessageToAll(0xFF6600, text);
PlayerPlaySound(playerid ,3200,0,0,0);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
GivePlayerWeapon(playerid, 26, 50000);
GivePlayerWeapon(playerid, 28, 50000);
return 1;
}
return 1;
}