28.10.2012, 18:25
Guys i have a problem with strcmp.. I make any cmd suppose anything it dosent work, i write the cmd in game but dosent work+ dosent give me any unknown command warning. why
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/snow", cmdtext, true, 5) == 0) // Put snow for all players (Administrator)
{
for(new i = 0; i <MAX_PLAYERS; i++){
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)){
if(SnowOff[i] == 0){
AttachObjectToPlayer(Snow[i], i, 1.5, 0.5, 0, 0, 1.5, 2);
SnowOff[i] = 0;}}}
return 1;
}
if (strcmp("/removesnow", cmdtext, true, 7) == 0) // Removed snow for all players (Administrator)
{
for(new i = 0; i <MAX_PLAYERS; i++){
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)){
if(SnowOff[i] == 1){
DestroyPlayerObject(i, Snow[i]);
SnowOff[i] = 1;}}}
return 1;
}
if (strcmp("/snowon", cmdtext, true, 7) == 0) // Put snow for you
{
if(SnowOff[playerid] == 0) return SendClientMessage(playerid, red, "Vous avez mit la neige pour vous.");
AttachObjectToPlayer(Snow[playerid], playerid, 1.5, 0.5, 0, 0, 1.5, 2);
SnowOff[playerid] = 0;
return 1;
}
if (strcmp("/snowoff", cmdtext, true, 8) == 0) // Remove snow for you
{
if(SnowOff[playerid] == 1) return SendClientMessage(playerid, red, "Vous avez enlever la neige pour vous.");
DestroyPlayerObject(playerid, Snow[playerid]);
SnowOff[playerid] = 1;
return 1;
}
return 0;
}
#include <a_samp>
#define red 0xFF0000AA
new Snow[MAX_PLAYERS];
new SnowOff[MAX_PLAYERS];
public OnFilterScriptInit()
{
for(new i = 0; i <MAX_PLAYERS; i++){
Snow[i] = CreatePlayerObject(i, 18864, 0, 0, 0, 0, 0, 0);}
return 1;
}
public OnPlayerConnect(playerid)
{
AttachObjectToPlayer(Snow[playerid], playerid, 1.5, 0.5, 0, 0, 1.5, 2);
SnowOff[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/snow", cmdtext, true, 5) == 0) // Включить снега для всех игроков.
{
for(new i = 0; i <MAX_PLAYERS; i++){
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)){
if(SnowOff[i] == 1){
AttachObjectToPlayer(Snow[i], i, 1.5, 0.5, 0, 0, 1.5, 2);
SnowOff[i] = 0;}}}
return 1;
}
if (strcmp("/nosnow", cmdtext, true, 7) == 0) // Отключить Снег для всех игроков.
{
for(new i = 0; i <MAX_PLAYERS; i++){
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)){
if(SnowOff[i] == 0){
DestroyPlayerObject(i, Snow[i]);
SnowOff[i] = 1;}}}
return 1;
}
if (strcmp("/snowon", cmdtext, true, 7) == 0) // Включить снега для игрока, если игрок отключил его раньше.
{
if(SnowOff[playerid] == 1){
AttachObjectToPlayer(Snow[playerid], playerid, 1.5, 0.5, 0, 0, 1.5, 2);
SendClientMessage(playerid, red, "Вы включили снег для себя.");
SnowOff[playerid] = 0;}
return 1;
}
if (strcmp("/snowoff", cmdtext, true, 8) == 0) // Отключить снег только 1 игрок.
{
if(SnowOff[playerid] == 0){
DestroyPlayerObject(playerid, Snow[playerid]);
SendClientMessage(playerid, red, "Вы отключили снега для себя.");
SnowOff[playerid] = 1;}
return 1;
}
return 0;
}