Problem with /vchat
#1

Why not working my code here:

PHP код:
CMD:vchat(playerid,params[]){
    if(
V[playerid][vlevel] > 0){
        var 
text;
        if(
sscanf(params,"s[40]",text))return SCM(playerid,-1,"Use:/vchat [Text]");
        var 
t[256];
        
format(t,sizeof(t),"%s",text);
        
SendMessageToVips(playerid,t);
    }
    else{
        
EMess(playerid);
    }
    return 
1;
}
//Function here 
//i like javascript and use #define function%0(%1) forward%0(%1); ..
function SendMessageToVips(id,string[]){
    for(var 
i=0i<MAX_PLAYERSi++){
        if(
IsPlayerConnected(i)){
            if(
V[i][vlevel] > 0){
                var 
name[MAX_PLAYER_NAME],str[256];
                
GetPlayerName(id,name,sizeof(name));
                
format(str,sizeof(str),"{FFFF00}Vip Chat: %s say %s",name,string);
                
SCM(i,-1,str);
            }
        }
    }
    return 
1;

and photo here

Reply
#2

Try this:
Код:
 #if !defined isnull
	#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
CMD:vchat(playerid,params[]){
    if(!V[playerid][vlevel]) return EMess(playerid);
    if(isnull(params)) return SCM(playerid,-1,"Use:/vchat [Text]");
    SendMessageToVips(playerid,params);
    return 1;
}

//Function here
//i like javascript and use #define function%0(%1) forward%0(%1); ..
function SendMessageToVips(id,const string[]){
    var str[145];
    GetPlayerName(id,str,MAX_PLAYER_NAME);
    format(str,sizeof(str),"{FFFF00}Vip Chat: %s say %s",str,string);
    for(var i; i<MAX_PLAYERS; i++){
        if(!IsPlayerConnected(i) || !V[i][vlevel]) continue;
        SCM(i,-1,str);
    }
    return 1;
}
PS: How do you declared var? I hope #define var new
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Try this:
Код:
 #if !defined isnull
	#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
CMD:vchat(playerid,params[]){
    if(!V[playerid][vlevel]) return EMess(playerid);
    if(isnull(params)) return SCM(playerid,-1,"Use:/vchat [Text]");
    SendMessageToVips(playerid,params);
    return 1;
}

//Function here
//i like javascript and use #define function%0(%1) forward%0(%1); ..
function SendMessageToVips(id,const string[]){
    var str[145];
    GetPlayerName(id,str,MAX_PLAYER_NAME);
    format(str,sizeof(str),"{FFFF00}Vip Chat: %s say %s",str,string);
    for(var i; i<MAX_PLAYERS; i++){
        if(!IsPlayerConnected(i) || !V[i][vlevel]) continue;
        SCM(i,-1,str);
    }
    return 1;
}
PS: How do you declared var? I hope #define var new
Thanks you very much for your code.
1)sorry I did not tell you about the var was my fault, yes i have #define var new for var variable why i like javascript .
2)this code is very good
Код:
#if !defined isnull
	#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
but i like sscanf and my problem no in /vchat my problem in function SendMessageToVips and i fix this function with code:

Код:
function SendMessageToVips(id,string[]){
    var name[MAX_PLAYER_NAME],str[256];
    GetPlayerName(id,name,sizeof(name));
	for(var i=0; i<MAX_PLAYERS; i++){
	    if(IsPlayerConnected(i)){
	        if(V[i][vlevel] > 0){
	            format(str,sizeof(str),"{FFFF00}Vip Chat: %s say %s",name,string);
	            SCM(i,-1,str);
	        }
	    }
	}
	return 1;
}
Thanks you very much and thank you for your time.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)