• Welcome to Vice City Multiplayer.
 

Some useful script

Started by Robd, March 21, 2011, 11:50:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Robd

This code is all made by me

Phone system:
else if (strcmp(cmd, "call", true) == 0) {
new plr;
tmp = strtok(cmdtext,idx);
plr = FindPlayerIDFromString(tmp);
if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid,COLOR_GREEN,"Please login first");
else if(PlayerInfo[playerid][call] != 100) SendClientMessage(playerid,COLOR_GREEN,"You are already in a call");
else if(!strlen(tmp)) SendClientMessage(playerid,COLOR_GREEN,"Use /c call <Nick/ID>");
else if(plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_GREEN,"Unknown player");
else if(PlayerInfo[plr][call] != 100) SendClientMessage(playerid,COLOR_GREEN,"You hear a busy tone");
else {
new szMsg[256];
format(szMsg,sizeof(szMsg),"Calling %s",gPlayers[plr]);
SendClientMessage(playerid,COLOR_GREEN,szMsg);
format(szMsg,sizeof(szMsg),"Incoming call from %s, use /c accept and /c decline",gPlayers[playerid]);
SendClientMessage(plr,COLOR_GREEN,szMsg);
PlayerInfo[plr][caller] = playerid;
}
return 1;
}
else if (strcmp(cmd, "accept", true) == 0) {
if(PlayerInfo[playerid][caller] == 100) SendClientMessage(playerid,COLOR_GREEN,"No one has called you");
else {
SendClientMessage(playerid,COLOR_GREEN,"You have accepted a call, use /c c <text> to talk");
SendClientMessage(PlayerInfo[playerid][caller],COLOR_GREEN,"Your call has been accepted, use /c c <text> to talk");
PlayerInfo[playerid][call] = PlayerInfo[playerid][caller];
PlayerInfo[PlayerInfo[playerid][caller]][call] = playerid;
PlayerInfo[playerid][caller] = 100;
}
}
else if (strcmp(cmd, "decline", true) == 0) {
if(PlayerInfo[playerid][caller] == 100) SendClientMessage(playerid,COLOR_GREEN,"No one has called you");
else {
SendClientMessage(playerid,COLOR_GREEN,"You have denied your call");
SendClientMessage(PlayerInfo[playerid][caller],COLOR_GREEN,"Your call has been denied");
PlayerInfo[playerid][caller] = 100;
}
}
else if (strcmp(cmd, "c", true) == 0) {
new szMsg[256];
tmp = strtok(cmdtext, idx);
if (PlayerInfo[playerid][call] == 100) SendClientMessage(playerid, COLOR_GREEN, "You are not in a call");
else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "/c c <text>");
else {
format(szMsg, sizeof(szMsg), "[Phone][%s]: %s", gPlayers[playerid], cmdtext);
SendClientMessage(PlayerInfo[playerid][call],COLOR_GREEN,szMsg);
SendClientMessage(playerid,COLOR_GREEN,szMsg);
}
return 1;
}
else if (strcmp(cmd, "hangup", true) == 0) {
if(PlayerInfo[playerid][call] == 100) SendClientMessage(playerid,COLOR_GREEN,"You are not in a call");
else {
SendClientMessage(playerid,COLOR_GREEN,"You hangup the phone");
SendClientMessage(PlayerInfo[playerid][call],COLOR_GREEN,"Phone call ended");
PlayerInfo[PlayerInfo[playerid][call]][call] = 100;
PlayerInfo[playerid][call] = 100;
}
}
You will also need to add the following to the PlayerInfo enum
call
caller


add PlayerInfo[playerid][call] = 100;
to OnPlayerConnect

and for a speedometer

public speedometer()
{
   for(new i = 0; i <= MAX_PLAYERS; i++) {
       if(IsPlayerConnected(i) == 1) {
   new Float:X,Float:Y,Float:Z,szMsg[256],MPH,distance;
   GetPlayerPos(i,X,Y,Z);
   distance = GetPointDistance(PlayerInfo[i][Xp],PlayerInfo[i][Yp],PlayerInfo[i][Zp],X,Y,Z);
   MPH = distance * 4;
   PlayerInfo[i][Xp] = X;
   PlayerInfo[i][Yp] = Y;
   PlayerInfo[i][Zp] = Z;
   format(szMsg,sizeof(szMsg),"~o~MPH ~r~%d",MPH);
   GameTextForPlayerBottom(i,szMsg);
       }
   }
}

stock GetPointDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
new Float:tmpdis;
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}

and to OnGameModeInit

SetTimer("speedometer",500,true);

and to the PlayerInfo enum

Float:Xp
Float:Yp
Float:Zp
Hello, this is Robd from the past.
If you are seeing this I have either posted something stupid, forgotten something, started a stupid topic, or a combination of the three.

Please forgive us for this mistake.

Regards, management

Castagna96


Castagna96

XDDD cool the call thing i understand now

Castagna96

something is wrong with the call thing when i try to put /c call it says you are in a call right now can u fix it plz !!

Robd

Quote from: Castagna96 on March 22, 2011, 04:11:47 AM
something is wrong with the call thing when i try to put /c call it says you are in a call right now can u fix it plz !!
Forgot something OnPlayerConnect

added to main post, just so you dont have to sift

QuoteAdd this to OnPlayerConnect
PlayerInfo[playerid][call] = 100;
Hello, this is Robd from the past.
If you are seeing this I have either posted something stupid, forgotten something, started a stupid topic, or a combination of the three.

Please forgive us for this mistake.

Regards, management

tato

Quote from: Robd on March 27, 2011, 07:20:56 AM
Quote from: Castagna96 on March 22, 2011, 04:11:47 AM
something is wrong with the call thing when i try to put /c call it says you are in a call right now can u fix it plz !!
Forgot something OnPlayerConnect

added to main post, just so you dont have to sift

QuoteAdd this to OnPlayerConnect
PlayerInfo[playerid][call] = 100;
allright thanks





<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

tato

and what's wrong with the speedometer





<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

yazeen

Those Who are Not  Using Gups can use this Add this on Top:

new Call[MAX_PLAYERS];
new Caller[MAX_PLAYERS];


and change the lines like this

else if (strcmp(cmd, "call", true) == 0) {
new plr;
tmp = strtok(cmdtext,idx);
plr = FindPlayerIDFromString(tmp);
if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid,COLOR_GREEN,"Please login first");
else if(Call[playerid], != 100) SendClientMessage(playerid,COLOR_GREEN,"You are already in a call");
else if(!strlen(tmp)) SendClientMessage(playerid,COLOR_GREEN,"Use /c call <Nick/ID>");
else if(plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_GREEN,"Unknown player");
else if(Call[plr], != 100) SendClientMessage(playerid,COLOR_GREEN,"You hear a busy tone");
else {
new szMsg[256];
format(szMsg,sizeof(szMsg),"Calling %s",gPlayers[plr]);
SendClientMessage(playerid,COLOR_GREEN,szMsg);
format(szMsg,sizeof(szMsg),"Incoming call from %s, use /c accept and /c decline",gPlayers[playerid]);
SendClientMessage(plr,COLOR_GREEN,szMsg);
Caller[playerid] = playerid;
}
return 1;
}
else if (strcmp(cmd, "accept", true) == 0) {
if(Caller[playerid] == 100) SendClientMessage(playerid,COLOR_GREEN,"No one has called you");
else {
SendClientMessage(playerid,COLOR_GREEN,"You have accepted a call, use /c c <text> to talk");
SendClientMessage(Caller[playerid],COLOR_GREEN,"Your call has been accepted, use /c c <text> to talk");
Call[playerid],= Caller[playerid],
[playerid][caller]][call] = playerid;
Caller[playerid], = 100;
}
}
else if (strcmp(cmd, "decline", true) == 0) {
if(Caller[playerid], == 100) SendClientMessage(playerid,COLOR_GREEN,"No one has called you");
else {
SendClientMessage(playerid,COLOR_GREEN,"You have denied your call");
SendClientMessage(Caller[playerid],COLOR_GREEN,"Your call has been denied");
Caller[playerid], = 100;
}
}
else if (strcmp(cmd, "c", true) == 0) {
new szMsg[256];
tmp = strtok(cmdtext, idx);
if (Call[playerid] == 100) SendClientMessage(playerid, COLOR_GREEN, "You are not in a call");
else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "/c c <text>");
else {
format(szMsg, sizeof(szMsg), "[Phone][%s]: %s", gPlayers[playerid], cmdtext);
SendClientMessage(Call[playerid],COLOR_GREEN,szMsg);
SendClientMessage(playerid,COLOR_GREEN,szMsg);
}
return 1;
}
else if (strcmp(cmd, "hangup", true) == 0) {
if(Call[playerid]== 100) SendClientMessage(playerid,COLOR_GREEN,"You are not in a call");
else {
SendClientMessage(playerid,COLOR_GREEN,"You hangup the phone");
SendClientMessage(Call[playerid],COLOR_GREEN,"Phone call ended");
playerid[call]][call] = 100;
Call[playerid] = 100;
}
}


Hope it Helps!

tato

Quote from: yazeen on March 27, 2011, 02:12:29 PM
Those Who are Not  Using Gups can use this Add this on Top:

new Call[MAX_PLAYERS];
new Caller[MAX_PLAYERS];


and change the lines like this

else if (strcmp(cmd, "call", true) == 0) {
new plr;
tmp = strtok(cmdtext,idx);
plr = FindPlayerIDFromString(tmp);
if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid,COLOR_GREEN,"Please login first");
else if(Call[playerid], != 100) SendClientMessage(playerid,COLOR_GREEN,"You are already in a call");
else if(!strlen(tmp)) SendClientMessage(playerid,COLOR_GREEN,"Use /c call <Nick/ID>");
else if(plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_GREEN,"Unknown player");
else if(Call[plr], != 100) SendClientMessage(playerid,COLOR_GREEN,"You hear a busy tone");
else {
new szMsg[256];
format(szMsg,sizeof(szMsg),"Calling %s",gPlayers[plr]);
SendClientMessage(playerid,COLOR_GREEN,szMsg);
format(szMsg,sizeof(szMsg),"Incoming call from %s, use /c accept and /c decline",gPlayers[playerid]);
SendClientMessage(plr,COLOR_GREEN,szMsg);
Caller[playerid] = playerid;
}
return 1;
}
else if (strcmp(cmd, "accept", true) == 0) {
if(Caller[playerid] == 100) SendClientMessage(playerid,COLOR_GREEN,"No one has called you");
else {
SendClientMessage(playerid,COLOR_GREEN,"You have accepted a call, use /c c <text> to talk");
SendClientMessage(Caller[playerid],COLOR_GREEN,"Your call has been accepted, use /c c <text> to talk");
Call[playerid],= Caller[playerid],
[playerid][caller]][call] = playerid;
Caller[playerid], = 100;
}
}
else if (strcmp(cmd, "decline", true) == 0) {
if(Caller[playerid], == 100) SendClientMessage(playerid,COLOR_GREEN,"No one has called you");
else {
SendClientMessage(playerid,COLOR_GREEN,"You have denied your call");
SendClientMessage(Caller[playerid],COLOR_GREEN,"Your call has been denied");
Caller[playerid], = 100;
}
}
else if (strcmp(cmd, "c", true) == 0) {
new szMsg[256];
tmp = strtok(cmdtext, idx);
if (Call[playerid] == 100) SendClientMessage(playerid, COLOR_GREEN, "You are not in a call");
else if (!strlen(tmp)) SendClientMessage(playerid, COLOR_GREEN, "/c c <text>");
else {
format(szMsg, sizeof(szMsg), "[Phone][%s]: %s", gPlayers[playerid], cmdtext);
SendClientMessage(Call[playerid],COLOR_GREEN,szMsg);
SendClientMessage(playerid,COLOR_GREEN,szMsg);
}
return 1;
}
else if (strcmp(cmd, "hangup", true) == 0) {
if(Call[playerid]== 100) SendClientMessage(playerid,COLOR_GREEN,"You are not in a call");
else {
SendClientMessage(playerid,COLOR_GREEN,"You hangup the phone");
SendClientMessage(Call[playerid],COLOR_GREEN,"Phone call ended");
playerid[call]][call] = 100;
Call[playerid] = 100;
}
}


Hope it Helps!
i 'll try thanks ;D





<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

Robd

Quote from: tato on March 27, 2011, 09:33:37 AM
and what's wrong with the speedometer

wow i always forget stuff
add this to PlayerInfo

incar

and then

OnPlayerEnterVehicle

PlayerInfo[playerid][incar] = 1;
OnPlayerExitVehicle
PlayerInfo[playerid][incar] = 0;
Hello, this is Robd from the past.
If you are seeing this I have either posted something stupid, forgotten something, started a stupid topic, or a combination of the three.

Please forgive us for this mistake.

Regards, management

tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

tato






<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b

Madara

#12
Quote from: Robd on March 28, 2011, 04:10:22 AM
Quote from: tato on March 27, 2011, 09:33:37 AM
and what's wrong with the speedometer

wow i always forget stuff
add this to PlayerInfo

incar

and then

OnPlayerEnterVehicle

PlayerInfo[playerid][incar] = 1;
OnPlayerExitVehicle
PlayerInfo[playerid][incar] = 0;

Unnecessary function: "PlayerInfo [playerid] [incar] = 1;": "incar" because for that exist the function IsPlayerInAnyVehicle (playerid), and this function should be put in the "speedometer" next to "IsPlayerConnected (i)"

BIG[H]

Its Just Crashes The Server :P
My Guru FORUM MUST VISITmegavcmp.freeforums.org

BIG[H] = BIG HaLL

tato

Quote from: Madara on March 28, 2011, 08:36:30 PM
Quote from: Robd on March 28, 2011, 04:10:22 AM
Quote from: tato on March 27, 2011, 09:33:37 AM
and what's wrong with the speedometer

wow i always forget stuff
add this to PlayerInfo

incar

and then

OnPlayerEnterVehicle

PlayerInfo[playerid][incar] = 1;
OnPlayerExitVehicle
PlayerInfo[playerid][incar] = 0;

Unnecessary function: "PlayerInfo [playerid] [incar] = 1;": "incar" because for that exist the function IsPlayerInAnyVehicle (playerid), and this function should be put in the "speedometer" next to "IsPlayerConnected (i)"
I still need help with the speedometer





<!-- Facebook Badge START --><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" style="font-family: &quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Eduardo Estrada">Eduardo Estrada</a><br/><a href="http://es-es.facebook.com/eduardoeslindo" target="_TOP" title="Eduardo Estrada"><img src="http://badge.facebook.com/badge/697470158.6069.1979465113.png" width="120" height="272" style="b